DataGridView的需要隐藏滚动条,而滚动应当通过代码实现的 [英] Datagridview needs to hide Scrollbar, but scroll should be achievable through code

查看:2525
本文介绍了DataGridView的需要隐藏滚动条,而滚动应当通过代码实现的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个DataGrid中具有相同的列数

I have 2 Datagrids with same number of columns

DataGrid1中是只显示标题,
Datagrid2 只是它下面显示的所有数据。
在本质上,2网格的需要同步显示为1格。

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.

我的问题在这里我需要隐藏<$ C的水平滚动条$ C> DataGrid1中,而只是说对 datagrid2 显示。
当用户滚动的的 datagrid2 ,我需要以编程方式同步在 DataGrid1中头。

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.

任何人都可以提出?

推荐答案

试试这个..

dataGridViews1.ScrollBars = ScrollBars.None;

 private void dataGridViews2_Scroll(object sender, ScrollEventArgs e)
    {
       int offSetValue = dataGridViews1.HorizontalScrollingOffset;

      try 
          { 
            dataGridViews1.HorizontalScrollingOffset = offSetValue; 
          }
      catch { }

           dataGridViews1.Invalidate();
    }

这篇关于DataGridView的需要隐藏滚动条,而滚动应当通过代码实现的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆