Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Controlling the ToolboxItem control type during a drag operation

Controlling the ToolboxItem control type during a drag operation

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpvisual-studiodesigntutorialquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    astibich2
    wrote on last edited by
    #1

    I am currently writing a custom toolbox window for Visual Studio 2008, using the SDK. When the user drags from the list, I start a drag drop operation using ToolboxItem as the drag data. ToolboxItem tbi = new ToolboxItem(myControlType); IToolboxService serviceToolBox = (IToolboxService)GetService( typeof(IToolboxService)); object tbiSerialized = serviceToolBox.SerializeToolboxItem(tbi); this.DoDragDrop(tbiSerialized, DragDropEffects.Copy); When they drop the ToolBoxItem, I use the 'ToolboxItem.ComponentsCreated' event to write some extra setup code on the control void dropToolBoxItem_ComponentsCreated(object sender, ToolboxComponentsCreatedEventArgs e) { // write custom control config code here } However, I'm finding that I sometimes want control over the ToolboxItem control type, based on UI conditions during the drag. For example, I may want to create a different control on the designer if the user holds down the shift key. Sometimes I want to block the drop completely. Unfortunately, I don't see a way to change the ToolboxItem after I start the drag. It seems like the 'ToolboxItem.ComponentsCreating' event was meant for this kind of intervention, but I can't change the control type when the 'ToolboxItem.ComponentType' property is read only. I've tried a few hacks (like deleting the control after drop and re-creating the new control type), but none of it has worked out very well. Anyone have any ideas? Thanks, Aaron

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups