c# - can there be two different columns of type link in datagridview? -


if how handle cellcontentclick event of each separately? adding columns dynamically. heres code:-
datagridviewshow.columns.add(new datagridviewtextboxcolumn { headertext = "date", datapropertyname = "date", celltemplate = new datagridviewtextboxcell() });

datagridviewlinkcolumn tocomputer = new datagridviewlinkcolumn();         tocomputer.headertext = "status";         tocomputer.name = "link1";         tocomputer.usecolumntextforlinkvalue = true;         tocomputer.text = "save file";         tocomputer.activelinkcolor = color.white;         tocomputer.linkcolor = color.blue;         tocomputer.trackvisitedstate = true;         tocomputer.visitedlinkcolor = color.green;         datagridviewshow.columns.add(tocomputer);         datagridviewshow.cellcontentclick += (savefiletype_click);    datagridviewlinkcolumn tonet = new datagridviewlinkcolumn();         tolinx.headertext = " ";         tolinx.name = "link2";         tolinx.usecolumntextforlinkvalue = true;         tolinx.text = "send net";         tolinx.activelinkcolor = color.white;         tolinx.linkcolor = color.blue;         tolinx.trackvisitedstate = true;         tolinx.visitedlinkcolor = color.green;                     datagridviewshow.columns.add(tonet);         datagridviewshow.cellcontentclick += ("don't know how gets handled");   

the above code display 2 different columns of link type, can't figure out how handle each event separately?

private void savefiletype_click(object sender, datagridviewcelleventargs e)     {         selectedrow = e.rowindex;          if (e.columnindex == 0)         {             //some code goes here         }if (e.columnindex == 1 && (string)datagridviewshow[e.columnindex, e.rowindex].value != "complete")         {             //some code goes here         }     } 

you don't handle events separately. need handle oncellclick or cellcontentclick event. using datagridviewcelleventargs object e, can column , row clicked. based upon cell selected handle event differently

public void datagridview1_oncellclick(object sender,     datagridviewcelleventargs e) {     if (e.columnindex == yourlinkcolumnindexa)         //some code goes here.     else if (e.columnindex == yourlinkcolumnindexb)         //some code goes here. } 

so wire event in code have done, once.

i hope helps.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -