Click here to Skip to main content
15,902,938 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have a user control. In the user control, I have a datagridview and some other controls. I want to create properties for my user control with the full attributes of one datagridview as normal. Help me? Thanhk you very much?
/\jmot 26-Nov-14 5:06am    
what it means??
Maciej Los 26-Nov-14 6:02am    
If user control should expose all datagridview properties, why to write user control?
BillWoodruff 26-Nov-14 16:27pm    
Maciej's advice is very good: you would be crazy to try and systematically expose all the Properties of the DataGridView "manually." Just expose the DataGridView !

If you have a distinct (hopefully small) set of Properties, Fields, Methods, Events, etc., you want to expose, then it may be worth your time to systematically expose them.

1 solution

Try this one

public partial class UserControl1 : DataGridView
      public UserControl1()
Share this answer
Maciej Los 26-Nov-14 9:32am    
I doubt it is a problem. Please, read OP's question one more time. He want to expose DGV properties and methods outside the user control.
Er. Dinesh Sharma 26-Nov-14 9:50am    
You can expose property create property of that control

public DataGrid dgv { get; set; }

private void UserControl1_Load(object sender, EventArgs e)
dgv = this.datagirdView1;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900