I have a datagridview with the columns
col A | col B | ... | col M | col N
Now I want to freeze col N
on the right side, so that when the user scrolls the datagridview horizontally the columns A,..., M can be scrolled horizontally, but col N
remains frozen.
Now I have tried setting the Frozen
attribute for col N
but then all the columns to the left of the frozen column are also frozen, which I do not want.
The best that I have been able to come up with is to reverse the columns of the DataTable bound to the DataGridView so that it now has the order
col N | col M | ... | col B | col A
and then draw the DataGridView from RightToLeft
so that the columns are reversed again and then shown as
col A | col B | ... | col M | col N
Another solution that I tried is to extract the rightmost columns that have to be frozen and place them in a different DataGridView on the right side and the remaining columns in the original DataGridView and then synchronize the vertical scroll for both of them. Now my question is are there any better ways to do this, if not which of the above should I prefer?
or in other words :
How can I freeze columns on the right side of a datagridview without freezing the other columns ?