I have 2 Datagrids with same number of columns
Datagrid1
is displaying only headers,
Datagrid2
is just below it displaying all the data.
In essence, the 2 grid's need to be synchronised to appear as 1 grid.
My issue here is I need to hide the horizontal scrollbar of datagrid1
, but display only that for the datagrid2
.
When the user scroll's the datagrid2
, I need to programmatically synchronise the headers on datagrid1
.
Can anyone suggest?
Try this..
dataGridViews1.ScrollBars = ScrollBars.None;
private void dataGridViews2_Scroll(object sender, ScrollEventArgs e)
{
int offSetValue = dataGridViews1.HorizontalScrollingOffset;
try
{
dataGridViews1.HorizontalScrollingOffset = offSetValue;
}
catch { }
dataGridViews1.Invalidate();
}
You can set the DataGridViews ScrollBasr property to hide vertical scrollbar
e.g.
dataGridViews1.ScrollBars = ScrollBars.None;
or see other enumeration value at link http://msdn.microsoft.com/en-us/library/system.windows.forms.scrollbars
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With