Using a DataGridView, how can I make a specific column uneditable while the grid view itself has “Allow editing” enabled?
Also, how can I execute an event when the selected index in a ComboBox in the DataGridView has changed? Here, ComboBox is a column type.
Another question is, how can I make the header title aligned to the center? I can’t find the appropriate property.
You’ve got a few questions here.
Set the
ReadOnlyflag on the particular column you want to make uneditable.If it’s in your DataGridView, it’s not a ComboBox; it’s a DataGridViewComboBoxColumn. According to MSDN:
This one I’m not familiar with, as I’ve never tried it myself. It appears you want to subscribe to the
EditingControlShowingevent and then see if something like this works for you (with a little tweaking).Set the HeaderCell.Style.Alignment