Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Forms win
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 8-Jan-13 20:59pm
Comments
jibesh at 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
İbrahim Uylaş at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can create new classes derived from different DataGridViewColumn types and define the new property in your derived class.
public class DataGridTextBoxColumnEx : DataGridViewTextBoxColumn
{
  [Browsable(true)]
  public int Bump
  {
    get;
    set;
  }
}
and use it like this in your UI designer class.
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();  
}
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 389
1 Nirav Prabtani 268
2 Richard Deeming 250
3 _Amy 185
4 CHill60 170
0 OriginalGriff 8,104
1 Sergey Alexandrovich Kryukov 7,067
2 Maciej Los 4,039
3 Peter Leow 3,738
4 CHill60 2,912


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100