Missing scroll bars on datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form.
It has a datagrid which is disabled.
It has a button which enables the datagrid.
It has a dataadapter and a connection object and they are configured to get
some data.
It has a dataset with the code necessary to fill it using the dataadapter
and to bind the first table it to the datagrid.
When the button is pressed the datagrid is enabled as expected but the
scroll bars are not included.
Is there a fix?
 
Hi Richard,

Thanks for your posting!

I have reproduced out this issue. And then, I found that this is a known
issue of our product, it seems the scrollbar as the child control of
DataGrid did not become enable with DataGrid.Enable=true.

Now, I will provide you 2 workarounds:
1. Just find the scrollbar and explicitly enable it:
private void button1_Click(object sender, System.EventArgs e)
{
dataGrid1.Enabled = true;
foreach(Control c in this.dataGrid1.Controls)
{
System.Windows.Forms.ScrollBar sb = c as ScrollBar;
if (sb != null)
{
sb.Enabled = true;
}
}
}

2. Call PerformLayout method:
private void button1_Click(object sender, System.EventArgs e)
{
dataGrid1.Enabled = true;
dataGrid1.PerformLayout();
}
Please apply my suggestion above and let me know if it helps resolve your
problem. If you need further help, please feel free to tell me. Thanks
===================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top