【问题标题】:Scrolling on Panel instead DataGridView在 Panel 上滚动而不是 DataGridView
【发布时间】:2014-11-26 01:28:00
【问题描述】:

我想将我的 datagridview 插入带有滚动条的面板中。我所做的是将面板上的 AutoScroll 设置为 true,使 datagridview 填充面板并禁用其上的滚动条,但是当 datagridview 有很多元素时,滚动条没有显示在面板上。有什么想法吗?

【问题讨论】:

    标签: c# datagridview scroll scrollbar panel


    【解决方案1】:

    不要将DataGridView Dock.Fill 设为Panel,使其尽可能大,以显示所有Rows 和所有Columns

    您需要确定显示所有Columns 和所有Rows 所需的完整Size 没有Scrollbars

    int width = 0;
    int height = 0;
    foreach (DataGridViewColumn col in dataGridView1.Columns) width += col.Width;
    foreach (DataGridViewRow row in dataGridView1.Rows) height += row.Height;
    dataGridView1.Size = new Size(width,height);
    

    【讨论】:

    • 谢谢,正是我需要的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-08
    • 2011-07-10
    • 2013-07-26
    • 1970-01-01
    相关资源
    最近更新 更多