简体   繁体   中英

C# Winforms inherit usercontrol with objects and modify

I've created my usercontrol called ucn with a datagridview that fills the usercontrol.

after I've created another usercontrol inherited from ucn:

public partial class ucnRequest : ucn
{

and in designmode i see the datagridview:

用户控件继承

is ok, but I can't add columns for example.

in the main usercontrol I changed the Modifiers property to public but nothing changes...

thanks

I think this is because your UserControl will not by default act as a "container" control in the Windows Forms editor, so the Windows Forms editor will not expose its public properties.

To make it a "container" control in the Windows Forms editor you can add the following attribute to the class:

[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))] 
public class MyUserControl: System.Windows.Forms.UserControl
{
     ...

See here for more information: http://support.microsoft.com/kb/813450

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM