Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more: , +
How to Dynamically Freeze Column on Right side in c# win. form? As when freezing it, it stops showing the scroll bar.
dgvSales.Columns["Net Total"].Frozen = true;

"Net Total" column exists in the extreme right corner.

Thanks in advance
Posted
Updated 10-Mar-14 6:59am
v2

I didn't tried this solution, but it seems to be working:
http://stackoverflow.com/questions/3240201/in-datagridview-how-to-2-column-that-will-freeze[^]
 
Share this answer
 
v2
try this
C#
dgvSales.Columns["Net Total"].DisplayIndex = dgvSales.Columns.Count
 
Share this answer
 
Comments
agent_kruger 10-Mar-14 12:58pm    
sir, i said it already exists in the extreme right corner. Please read the question carefully again.
EduChapow 10-Mar-14 15:50pm    
so, ur problem is: the scrollbar are not visible when you setting the position of the column?

http://stackoverflow.com/questions/5218819/horizontal-scrollbar-is-not-visible-on-datagridview

agent_kruger 11-Mar-14 2:39am    
sir, that is what is in my case but i want to freeze the column and still show the scroll bar.
Why would go for code. Use smart tools instead. ;)

To freeze a column using the designer:
>> Choose Edit Columns from the control's smart tag.
>> Select a column from the Selected Columns list.
>> In the Column Properties grid, set the Frozen property to true.

And it seems that you might have passed the wrong column name. Might be spelling mistake or the space between words etc.
So make a column name proper and give it a try like,
this.dataGridView1.Columns["ColumnName"].Frozen = true;

-KR
 
Share this answer
 
Comments
agent_kruger 10-Mar-14 12:59pm    
my friend dynamically not manually.
Krunal Rohit 11-Mar-14 9:26am    
I have provided the code for that as well.

-KR
agent_kruger 11-Mar-14 11:17am    
name are also properly mentioned otherwise it would have prompted the error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900