K
Klaus Jensen
I have been battling with this problem for hours, and I am now completely
stuck.
The problem (simplified):
I have a databound datagridview, which has 3 columns: Name (text-column),
VerifiedDriversLicense (checkboxcolumn) and CarAssigned (databound
combobox-column)
If VerifiedDriversLicense checkbox is checked for a row, a value from the
databound CarAssigned Combobox can be chosen. If VerifiedDriversLicense is
NOT selected, I need to be able to make CarAssigned combobox invisible,
readonly, a different color or something like that.
This should be pretty straightforward, and I tried this approach:
First I run a sub to bind data
Then I run a sub to process the datagrid to apply the above mentioned logic:
Dim veriFiedDataGridViewCheckBoxCell As DataGridViewCheckBoxCell
Dim carAssignedDataGridViewComboBoxCell As DataGridViewComboBoxCell
For Each row As DataGridViewRow In DataGridView1.Rows
If row.Cells("colVerifiedDriversLicense").Value = 0 Then
carAssignedDataGridViewComboBoxCell =
CType(row.Cells("colCarAssignedDataGridViewComboBoxCell"),
DataGridViewComboBoxCell)
carAssignedDataGridViewComboBoxCell.Readonly = True
carAssignedDataGridViewComboBoxCell.Style.BackColor = Color.Black
End If
Next
(it's pseudocode, it might contain typos)
....But it does now work! I tried stepping through the code, and the
code-lines carAssignedDataGridViewComboBoxCell.Readonly = true are run, but
nothing happens. The combobox is NOT readonly
What am I missing? Is it not possible to make a combobox in a single cell
readonly?
stuck.
The problem (simplified):
I have a databound datagridview, which has 3 columns: Name (text-column),
VerifiedDriversLicense (checkboxcolumn) and CarAssigned (databound
combobox-column)
If VerifiedDriversLicense checkbox is checked for a row, a value from the
databound CarAssigned Combobox can be chosen. If VerifiedDriversLicense is
NOT selected, I need to be able to make CarAssigned combobox invisible,
readonly, a different color or something like that.
This should be pretty straightforward, and I tried this approach:
First I run a sub to bind data
Then I run a sub to process the datagrid to apply the above mentioned logic:
Dim veriFiedDataGridViewCheckBoxCell As DataGridViewCheckBoxCell
Dim carAssignedDataGridViewComboBoxCell As DataGridViewComboBoxCell
For Each row As DataGridViewRow In DataGridView1.Rows
If row.Cells("colVerifiedDriversLicense").Value = 0 Then
carAssignedDataGridViewComboBoxCell =
CType(row.Cells("colCarAssignedDataGridViewComboBoxCell"),
DataGridViewComboBoxCell)
carAssignedDataGridViewComboBoxCell.Readonly = True
carAssignedDataGridViewComboBoxCell.Style.BackColor = Color.Black
End If
Next
(it's pseudocode, it might contain typos)
....But it does now work! I tried stepping through the code, and the
code-lines carAssignedDataGridViewComboBoxCell.Readonly = true are run, but
nothing happens. The combobox is NOT readonly
What am I missing? Is it not possible to make a combobox in a single cell
readonly?