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;

            }

  • 相关阅读:
    48. Rotate Image
    47. Permutations II
    46. Permutations
    45. Jump Game II
    44. Wildcard Matching
    43. Multiply Strings
    42. Trapping Rain Water
    41. First Missing Positive
    40. Combination Sum II
    39. Combination Sum
  • 原文地址:https://www.cnblogs.com/mol1995/p/5964804.html
Copyright © 2011-2022 走看看