c# - Conditionally show buttons in DataGridView? -
how show buttons in cells of datagridview if, example, column has value?
private void dgv_cellformatting(object sender, datagridviewcellformattingeventargs e) { var dgv = (datagridview)sender; if (dgv.columns[e.columnindex].name == "btn") { var hide= dgv.rows[e.rowindex].cells[dgv.columns["a"].index].value dbnull; var cell = dgv.rows[e.rowindex].cells[dgv.columns["b"].index]; if (hide) { //cell.value = null; //cell = new datagridviewtextboxcell(); cell.visible = false; // dosn't work } } }
probably best way bind item_databound (i believe that's it's called) on grid view. check column see if contains value need. can hide specific controls in cell (using of code in post):
cell.controls[0].visible = false;
Comments
Post a Comment