I have created a Datagridview. Now whenever the cell contains an empty value, It will add the plus button to the cell. Something like this:
if ((string)((Hashtable)ht[i])["value"] == "")
{
// Create a Save button column
DataGridViewImageButtonSaveColumn columnSave = new DataGridViewImageButtonSaveColumn();
// Set column values
//Add the columns to the grid6
if (!dataGridView1.Columns.Contains("SaveButton"))
{
dataGridView1.Columns.Insert(5, columnSave);
}
}
else
{
//hide save button.
}
But now my problem is that it display the plus button at all cell for that column even though that particular cell have value. How can I hide the button for the cell that have value?
If you only want buttons in some rows then I would tend not to use a DataGridViewButtonColumn
. I would use a read-only DataGridViewTextBoxColumn
, so that it displays empty cells by default. For those rows where you want a button, you would then create a DataGridViewButtonCell
and use the indexer of the grid itself to place that cell at a specific column and row index.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.