C#Winform:DataGridView和UserControl [英] C# Winform : DataGridView and UserControl

查看:202
本文介绍了C#Winform:DataGridView和UserControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我在每一行的第一列中都有DataGridView(DGV)[使用DGV.GetCellDisplayRectangle(...)方法)我放置了UserControl(UC).但是,当行数增加时,它会将滚动条添加到DGV
然后我无法将UC移动到滚动位置,因为DGV.GetCellDisplayRectangle(...)每次都会返回Rectangle.X = 0和Rectangle.Y = 0(如果DGV.Cell是可见的). > 为什么?现在如何解决这个问题?

Hi All,
I have DataGridView(DGV) in its 1st column of every row [with DGV.GetCellDisplayRectangle(...) menthod) I placed UserControl(UC). But when row counts increases it adds scroll to DGV
And then i''m not able to move UC to scrolled location, Because DGV.GetCellDisplayRectangle(...) returns Rectangle.X = 0 and Rectangle.Y=0 every time (If DGV.Cell is visible).
Why? Now how to solve this problem?

void dgvMapper_Scroll(object sender, ScrollEventArgs e)
        {

                int intCnt = 0;
                foreach (UserControl ucEL)
                {
                    ucEL.Visible = false;
                    Rectangle rect = this.dgvMapper.GetCellDisplayRectangle(1, intCnt, false);
                    ucEL.Location = rect.Location;

                    ucEL.Size = rect.Size;
                    if (!(rect.X==0 && rect.Y==0 && rect.Height==0))
                        ucEL.Visible = true;
                    intCnt++;

                }

}


}

推荐答案

这里去了

http://social.msdn.microsoft.com/论坛/en-US/winforms/thread/d17ac33e-3e5f-4b36-aaf6-fb129f46ace2 [
here you go

http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/d17ac33e-3e5f-4b36-aaf6-fb129f46ace2[^]


这篇关于C#Winform:DataGridView和UserControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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