zoukankan      html  css  js  c++  java
  • 2015.1.4 判断鼠标点击DataGridView的第几行还是空白处

    public int GetRowIndexAt(int mouseLocation_Y)

    {

        if (dvaw.FirstDisplayedScrollingRowIndex < 0)

        {

          return -1;

         }

      if (dvaw.ColumnHeadersVisible == true && mouseLocation_Y <= dvaw.ColumnHeadersHeight)

          {

              return -1;

          }

     int index = dvaw.FirstDisplayedScrollingRowIndex;

     int displayedCount = dvaw.DisplayedRowCount(true);

      for (int k = 1; k <= displayedCount; )

                {

                    if (dvaw.Rows[index].Visible == true)

                    {

                        Rectangle rect = dvaw.GetRowDisplayRectangle(index, true);  // 取该区域的显示部分区域  

                        if (rect.Top <= mouseLocation_Y && mouseLocation_Y < rect.Bottom)

                        {

                            return index;

                        }

                        k++;

                    }

                    index++;

                }

                return -1;

            }

  • 相关阅读:
    使用RF(robotframework)要安装哪些库
    MYSQL题目练习专用
    MySQL字段拼接
    WPF样式
    WPF数据模板
    WPF控件模板
    WPF布局
    面向对象程序设计原则
    设计模式之策略模式
    设计模式之简单工厂模式
  • 原文地址:https://www.cnblogs.com/mol1995/p/5964804.html
Copyright © 2011-2022 走看看