I was wondering if its possible to make a single comboBox not visi开发者_StackOverflow中文版ble or disabled for only that certain row?
right now I have something like
private void gvAirSegment_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex+1 == gvAirSegment.Columns["RemarkLine"].Index)
{
if (!gvAirSegment.CurrentCell.Selected)
{
gvAirSegment.Columns[2].Visible = true;
}
else
{
gvAirSegment.Columns[2].Visible = false;
}
}
}
which on click of a checkbox it hides the entire column, but I would like it so only that combobox is not visible/disabled.
If I could get the control that would be the best, if I could turn it into a GridViewComboBox into a comboBox control
Thanks
Because the combobox is tied to the cell type, you can't really hide it without hiding the whole cell, if I understand your question. You can, however, set the control to be read-only.
gvAirSegment.Rows[e.RowIndex].Cells[2].ReadOnly = true;
You can assign a new instance of the base class DataGridViewCell
to the appropriate column and row for any cell you would like to hide from the user:
gvAirSegment.Rows[row].Cells[col] = new DataGridViewCell();
Don't forget to assign a Value
, as overwriting the cell will destroy the stored value.
This technique probably won't work if the DataGridView
is bound to a data source, or running in virtual mode.
精彩评论