c# - Deriving DataGridViewButtonColumn class and changing Button object -


i tried create child class of datagridviewbuttoncolumn stuck. property can change flatstyle part of button class. change forecolor (there other things well, forecolor example please don't stick that, i.e. don't use workaround defaultcellstyle). have somehow retrieve button object datagridviewbuttoncolumn. inside datagridviewbuttoncolumn there datagridviewbuttoncell. class (i believe) holds button , has property named value (derived datagridviewcell) null in datagridviewbuttoncell's constructor can't access there. how otherwise can have influence on button object inside cell?

here's example of i'm trying do:

public class mydatagridviewbuttoncolumn : datagridviewbuttoncolumn {     public mydatagridviewbuttoncolumn () : base()     {         ((button)((datagridviewbuttoncell)this.celltemplate).value).forecolor = color.red;     } } 

i'm new manipulating existing .net controls msdn not "support" it, meaning not document examples of how so. attempts base on looking .net framework's code , learn there.

i checked how implemented flatstyle, tought call button object , set value whatever specify. however, implementation uknown me.

public flatstyle flatstyle {     set     {         if (!clientutils.isenumvalid(value, (int)value, 0, 3))         {             throw new invalidenumargumentexception("value", (int)value, typeof(flatstyle));         }         if (value != this.flatstyle)         {             base.properties.setinteger(datagridviewbuttoncell.propbuttoncellflatstyle, (int)value);             base.oncommonchange();         }     } } 

it looks changes properties class each property (like flatstyle) has it's own integer value? work same way properties? doubt it's documented?

edit: see correctly button literally drawn inside cell , not created object?

check out solution:

change color of button in datagridview cell

but read past selected answer , think should focus on answer provided mike yasieniuk who's answer up-voted more.

hopefully help.


Comments