Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone,
I created new component that is inherited by dataGridView. I can add a new browsable property to mydataGridView. Also I want to add property for column of mydataGridView. It should be browsable. Because i want to see on properties windows. It's type is not important, may be int or string. Then i should use in code like "mydataGridView1.Columns[0].MyProperty = 100;".

How can i do this?

Thanks,
Ibrahim Uylas
Posted
Comments
Jibesh 9-Jan-13 3:17am    
But what type of DataGridColumn you are going to use? this property should be available for all the DataGridColumn types ie TextBox,Combo,CheckBox etc
Ibrahim Uylas 9-Jan-13 3:30am    
All of them. This property should be like Column Text. I don't want to use Tag property. If i don't find any solution i will use it.

1 solution

You can create new classes derived from different DataGridViewColumn types and define the new property in your derived class.
C#
public class DataGridTextBoxColumnEx : DataGridViewTextBoxColumn
{
  [Browsable(true)]
  public int Bump
  {
    get;
    set;
  }
}

and use it like this in your UI designer class.
C#
private void InitializeComponent()
{
  //replace the following code all the references to your derived class
  this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
 to 
  this.Column2 = new DataGridTextBoxColumnEx();  
}
 
Share this answer
 

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