Data Source drag/drop not allowed on inherited form

G

Guest

In VS 2005 I have a base form that is designed to be inherited by many other
forms within an application. This base form contains a tab control with two
tab pages, among several other controls. The second tab page (lets call it
TabPage2) has the Modifiers property set to Protected so that any inherited
forms can add controls to the tab.

When I create an inherited form, I can drag new controls from the toolbar to
TabPage2 without a problem. However, what I would really like to do is drag
a table (or selected fields) from the Data Sources pane so that the data
bound form fields are created automatically. That would be a wonderful
convenience. The only problem is, when I try to drag a field over TabPage2,
I get the "not allowed" cursor symbol and the drop operation does nothing.

As another point of interest, this base form was brought over from a VS 2003
project that is being converted and upgraded using VS 2005. I'm not sure if
the version change is affecting the outcome or not. The base form and its
related code are a little complex.

In an effort to isolate the problem, I started a new project and created a
very simple form with the same tab control design. When I inherited this
simple base form and tried to drag from the Data Source window, it worked
perfectly. Very mysterious. Something in the old base form is preventing
the drag and drop operation from working (although not for regular toolbar
controls).

Any ideas on how to isolate or debug this?

Thanks.
 
L

Linda Liu [MSFT]

Hi Jo-Anne,

Thank you for posting.

I have performed a test on this issue and confirmed that the problem is not
related to the project's conversion from VS 2003 to VS 2005.

In fact, when a control is dragged from toolbar and dropped onto the
TabPage2, what the VS IDE does is to generate some code such as creating
new control, adding it to the Controls property of the TabPage2, binding
the control to a data source and so on in the InitializeComponent method in
the inherited form.

I think if VS IDE couldn't generate all these corresponding code, the
drag&drop operation will be forbidden.

Since you could drag&drop regular toolbar controls onto the TabPage2 in the
inherited form, the code of creating controls and adding them to the
Controls property of the TabPage2 are able to generated.

You may have a try dragging the table from Data Source pane and dropping it
onto the inherited form itself to see if the drop operation works. If the
result is Yes, the code of the data binding is able to generated.

You may comment out all the code within the InitializeComponent method of
the inherited form and drag&drop the table onto the TabPage2.

Hope this helps.


Sincerely,
Linda Liu
Microsoft Online Community Support

============================================================================
=============================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

With newsgroups, MSDN subscribers enjoy unlimited, free support as opposed
to the limited number of phone-based technical support incidents. Complex
issues or server-down situations are not recommended for the newsgroups.
Issues of this nature are best handled working with a Microsoft Support
Engineer using one of your phone-based incidents.

============================================================================
=============================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Linda,

Thanks for pointing me in the right direction. After much selective
commenting of code, I determined the problem was caused by a line in the
InitializeComponent routine. Believe it or not, the code was:

Me.WindowState = System.Windows.Forms.FormWindowState.Maximized

One may wonder:
1. Why would that code appear in the InitializeComponent code of a base
(template) form?
2. Why does the Visual Studio designer even care?

As I mentioned, this is an existing application being converted from VS 2003
to VS 2005. I really can't speculate why someone thought that line was
needed. When I removed the line, I was able to drag and drop fields from the
Data Source window onto an inherited form. When I put that one line back in,
the drag problem reappeared. Surprising, to say the least.

I suppose the more intriguing question is why that code causes the VS 2005
IDE to think that it is unable to to place a new data bound control on the
inherited form. Since I spent quite a few hours on this issue already, I
will happily move on with my solution even though I don't fully understand
why it worked.

Thanks for your assistance.

Regards,
Jo-Anne V
 
L

Linda Liu [MSFT]

Hi Jo-Anne,

Thank you for your update and detailed feedback. I am glad to hear that the
problem has been fixed.

I have performed a test based on your feedback and reproduced the problem.
I also found that I couldn't drag&drop table from the Data Sources panel
onto the inherited form as well. What's more, although I could drag&drop
common controls onto the inherited form, I couldn't resize these controls
on the inherited form with the Mouse.

If I set the WindowsState of the base form to Normal, the above problems
don't exist. Thus, if you want to set the WindowsState of the base form, I
recommend you to place the statement in the form's Load event handler.

I think it is an issue of VS2005. Thank you for reporting this to us.

If you have any other questions in the future, please don't hesitate to
contact us. It is always our pleasure to be of assistance.

Have a nice day!


Sincerely,
Linda Liu
Microsoft Online Community Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top