Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to enable scroll bar options of datagridview while DataGridView select ability is disabled. help me with this.THANX?
dataGridView1.Enabled = false;
Posted
Updated 5-Jan-13 7:38am
v2

GridView still have not ScrollBars property. To create GridView with horizontal or vertical scrollbar you need to place GridView inside <div > tag or inside Panel control.
GridView inside <div > HTML tag
To produce GridView scrollbars with div tag, use this code:
<div style="width:100%; height:300; overflow:auto;">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>

GridView inside Panel Control
To create GridView scrollbars with a little help of Panel control, use this code:
<asp:Panel ID="Panel1" runat="server" ScrollBars="Both" Height="300" Width="100%">
 <asp:GridView ID="GridView1" runat="server">
 </asp:GridView>
</asp:Panel>
 
Share this answer
 
By setting the
C#
DataGridView.Enabled=false;
you are making the DataGridViewControl disabled for any operation.To use the scroll bar you can try the following other options.

a) DataGridView.ReadOnly = false;
b) dataGridColumn.ReadOnly = false;
c) addition to a or b, change the SelectionBackColor to white in DefaultCellStyle
d) call dataGridView.ClearSelection() method in your cell/row selection change method.
 
Share this answer
 

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