Forum  Commercial Foru...  Commercial Foru...  VWG 6.4 User Control as a Drop Target
Previous Previous
 
Next Next
New Post 12/13/2011 5:53 PM
  egirardi
66 posts
No Ranking


VWG 6.4 User Control as a Drop Target 
Modified By egirardi  on 12/13/2011 9:55:08 PM)

Hello I created a user control, added it to a form. On that for i have a listbox with some items in it.

I set the Usercontrol as a drop target of the ListBox.  I set the Usercontrol to allowdrop to True. When i drag an item from the listbox to the user control, the UserControl1_DragDrop event does not fire. Am i doing something wrong ?

 
New Post 12/14/2011 10:42 AM
  palli
11824 posts
1st Level Poster




Re: VWG 6.4 User Control as a Drop Target 

Hi egirardi,

I tested this scenario here in the upcoming 6.4.0 Release d, and was not able to see any problem. The DragDrop event of the UserControl fires fine.

Two things come to mind, and you seem to already have covered the first one. You need to set the UserControl1 as a member of the ListBox.DragTargets. Second, having UserControl1 as the DragTargets or the ListBox would mean that you could only drop a ListBox item on an "empty space" within the UserControl1. If you drop it on, say, a TextBox within UserControl1, that control is not a member of ListBox.DragTargets, unless you explicitly set it, so you would get no DragDrop event fired. In addition, in that case, the DragDrop event of the TextBox should fire.

Hope this explains,

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 12/14/2011 12:12 PM
  egirardi
66 posts
No Ranking


Re: VWG 6.4 User Control as a Drop Target 

Its the textbox on the user control that i want the drop even to fire on, but how do you set the the text box on a user control to be a drop target on a listbox that exists on the main form ?

 
New Post 12/14/2011 1:03 PM
  palli
11824 posts
1st Level Poster




Re: VWG 6.4 User Control as a Drop Target 

Hi egirardi,

I kind of suspected that was the case, that you wanted some internal controls of the UserControl to be the actual targets.

There are zillion ways to make this work. One of them might be to add a function to your UserControl, and have that function or readonly property return an array of Component of the internal controls that you do want to serve as dragtargets inside the UserControl. Let's say you have a UserControl with a TextBox1 and Button1 that you want for this purpose. Your C# readonly property might then look like this:

 

        public Gizmox.WebGUI.Forms.Component[] getInternalDragTargets
        {
            get
            {
                Gizmox.WebGUI.Forms.Component[] objTargets = 
                    new Gizmox.WebGUI.Forms.Component[] 
                    {   this.button1,
                        this.textBox1 };
 
                // Make sure all the internal controls allow drop
                foreach (Gizmox.WebGUI.Forms.Component ctrl in objTargets) {
                    ((Control) ctrl).AllowDrop = true ;
                }
 
                // You also must make sure the internal controls do have a registered
                // DragDrop event handler and they know what to do with "their" drops.
                return objTargets;
            }
        }

Then in your ListBox, you need to set ListBox1.DragTargets = UserControl1.getInternalDragTargets and you should have this working as expected.

Hope this helps,

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 12/27/2011 4:23 AM
  egirardi
66 posts
No Ranking


Re: VWG 6.4 User Control as a Drop Target 

 This worked, Thanks!

 
Previous Previous
 
Next Next
  Forum  Commercial Foru...  Commercial Foru...  VWG 6.4 User Control as a Drop Target
Azure banner
.NET Web, Cloud and Mobile application delivery platform | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2011 Visual WebGui®       Visual WebGui weblog on ASP.NET Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS