简体   繁体   中英

Prevent readonly columns from reorder

I have a DataGridView 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM