Prevent readonly columns from reorder
I have a D开发者_如何学运维ataGridView that has three read only columns in it and one or several other writable columns. The users have decided they need to be able to reorder the columns. I need a way to allow them them to reorder the writable columns but not the read only ones. The only thing I have thought of is to check if the column that was just moved in the ColumnDisplayIndexChanged
event is read only, check it's name and then move it back to where I want it. I don't like that solution. Does anyone have a more elegant solution to this problem?
If column reordering is enabled, the frozen columns are treated as a group distinct from the unfrozen columns. Users can reposition columns in either group, but they cannot move a column from one group to the other.
Does this sound like what you want?
http://msdn.microsoft.com/en-us/library/28e9w2e1.aspx
You could disable column reordering by default, and only enable it when the mouse cursor is over a column that you want to be moved.
Not that I actually tried this, but it's worth a try.
精彩评论