I've created user control which hosts datagridview and other controls.
Then I drop it onto a form.
How do I allow myself to customize grid's properties (like which columns are shown) in a target form?
I thought setting its modifier to public will suffice.
Asked
Active
Viewed 427 times
0

Nickolodeon
- 2,848
- 3
- 23
- 38
-
1possible duplicate of [How to "bubble" a Controls features when place in a custom UserControl](http://stackoverflow.com/questions/2785376/how-to-bubble-a-controls-features-when-place-in-a-custom-usercontrol) – Hans Passant Dec 16 '10 at 18:44
3 Answers
1
That should do it, then you can address the grid through your user control instance. Assuming you control is named "MyControl" and your grid within the control is named "MyGrid" then you should be able to use MyControl.MyGrid.
to get to the properties.

Lazarus
- 41,906
- 4
- 43
- 54
0
You can add properties to your UserControl that helps you to change design of your Control from different forms.

Javed Akram
- 15,024
- 26
- 81
- 118
-
Perhaps you mean those properties that will appear under "miscellanous" tab of UserControl properties (in categorized view). I can do something like public string DisplayText { get { return userControlTextBox.Text} set { ... . But I need the ability to interract with controls directly (with the mouse), so that when I click control hosted by UserControl hosted by my form I would get properties of that control, especcially DataGridView (or XtraGrid). – Nickolodeon Dec 17 '10 at 08:55
-
Placing [Browsable(true)] [EditorBrowsable(EditorBrowsableState.Always)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] onto my grid in UserControl's InitializeComponent did NOT help either ((( – Nickolodeon Dec 17 '10 at 09:23
0
Problem not solved in that general way I initially posed it.
As a quick hack I declared public properties for some of the grid properties I needed (like Columns collection)
Tnanx for your help, though.

Nickolodeon
- 2,848
- 3
- 23
- 38