Reputation: 63
I have a datagrid, not a datagridview, where I wan to make a column read only if radio button is checked or not.
So I define the column dynamically from a sql query:
Dim bool_col As New FormattableBoolColumn
bool_col.HeaderText = "Bool Colunm"
bool_col.MappingName = "bool_col"
Also on the form are two radio buttons, lets call them A and B.
When A is checked I want to set the bool_col to read only is true.
When B is checked I want to set the bool_col to read only is false.
Let me know if anything else is needed. I'm using the Click event but I can't figure out how to find the column in the Datagrid and set it to read only. Spent all afternoon trying to do that and searched everything I can think of with no luck. And I can't change it to a datagridview unfortunately. Time and and money constraints on the project prohibit this.
Thanks in advance!
Upvotes: 0
Views: 360
Reputation: 121
When you create the column you can add a check:
bool_col.ReadOnly = RadioButtonA.Checked
So the read only property of the column will be true if A is checked and false if A is not.
Now this assumes that your radio buttons are in a group so only one of the two can be checked at a time.
If the radio buttons are not in a group then use:
If RadioButtonA.Checked Then
bool_col.ReadOnly = true
else if RadioButtonB.Checked Then
bool_col.ReadOnly = false
End If
Upvotes: 1