Windows Develop Bookmark and Share   
 index > Windows Forms Designer > How to change ParentControlDesigner behavior
 

How to change ParentControlDesigner behavior

Hi,

I want to implement a control designer for my own usercontrol. I derived my control designer from the ParentControlDesigner. When I drag and drop a datasource to the user control design surface, a DataGridView will be added to the user control.

The question is: Can I change this default behavior?

When a datasource dropped on the usercontrol surface, may I just add some labels on the usercontrol surface and show the column names on each label?

thanks
ZC
ZCH  Monday, April 20, 2009 2:04 AM
Hi, Kira

Are you dragging the DataSet or DataTable?

I created a NorthWindDataSet, which contains a Employees DataTable.

Just now I try it again. I found I can change the default control by click the Employees table in datasource toolbox.


Thanks a lot.

ZC
ZCH  Wednesday, April 22, 2009 9:31 AM

Hi ZCH,

"When I drag and drop a datasource to the user control design surface, a DataGridView will be added to the user control."
What type of DataSource did you drag?

could you please show some code of the your derived ParentControlDesigner?

Sincerely,
Kira Qian


Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Tuesday, April 21, 2009 9:53 AM
Hi, Kira

I didn't add any code to my designer. I jsut derived from the ParentControlDesigner and attached to the usercontrol.

The question is if I drag a DataSource to the usercontrol, a datagridview control will be created automatically and added to the usercontrol design surface. May I change this default behavior?

Thanks
Best regards
ZC
ZCH  Tuesday, April 21, 2009 10:19 AM

Hi ZCH,

Is the DataSource a DataSet or something else?

If you create a class inherited from ParentControlDesigner and use it for your usercontrol without adding any code, it just change your usercontrol into a desinger surface allow any design action.

As you said, when a datasource is draged onto the designer surface, a DataGridView will be added. This action is related to the DataSource's designer not your derived ParentControlDesigner.

So please tell me what kind of DataSource first.

Sincerely,
Kira Qian


Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Wednesday, April 22, 2009 8:49 AM
Hi, Kira

Yes, the data source is a DataSet. So your mean a DataSet has it's own designer?


Thanks
ZC
ZCH  Wednesday, April 22, 2009 8:54 AM

Hi ZCH,

If you use Reflector to view the source code of CLR, you can see the designer of DataSet is called "Microsoft.VSDesigner.Data.VS.DataSetDesigner" under "Microsoft.VSDesigner.dll" version 8.0.0.0. I never reach that designer class yet.

Once I test to drag a DataSet onto my user control with derived ParentControlDesigner as its designer. I don't see any DataGridView followed. Is any special on your form?

If I misunderstood something, please feel free to tell me.

Sincerely,
Kira Qian


Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Wednesday, April 22, 2009 9:14 AM
Hi, Kira

Are you dragging the DataSet or DataTable?

I created a NorthWindDataSet, which contains a Employees DataTable.

Just now I try it again. I found I can change the default control by click the Employees table in datasource toolbox.


Thanks a lot.

ZC
ZCH  Wednesday, April 22, 2009 9:31 AM

You can use google to search for other answers

Custom Search

More Threads

• Drag n' drop
• Referencing Label Objects
• Bug (reproducable) with VS2005 Form Designer - release build
• Why "PropertyBinding" dosen't work with the "Checked" property of "ToolStripMenuItem"?
• Combobox Help to Bind 3 Columns from database
• Control Overlap (weird!)
• 100% CPU Usage in Design Time.
• how to host different controls in the same column in DataGridView control
• Urgent for Tabindex in UserControl
• UserControl problem...