zoukankan      html  css  js  c++  java
  • [C#]WinFrom中的DataGrid单击选择行

    在WebFrom中,做单击选择行很简单,但在WinFrom中就有点烦了.

    记得WebFrom中在javascript里写得那么两条语句就OK了.那么在WinFrom中呢?呵,去MSDN里搜了一把.得到个结果可以完成了!^o^

    在窗口类中加入如下方法:

      public void InIt()
      {
       foreach(DataGridColumnStyle dgCol in dataGridTableStyle1.GridColumnStyles )
       {
        DataGridTextBoxColumn dgbc = dgCol as DataGridTextBoxColumn;
        dgbc.TextBox.Enter += new EventHandler( OnSelectedTheLine );
       }
      }

      private void OnSelectedTheLine( object sender , EventArgs e )
      {
       Control txtContentBox = sender as Control;
       txtContentBox.Visible = false;
       DataGrid dgParent = txtContentBox.Parent as DataGrid;
       dgParent.Select( dgParent.CurrentCell.RowNumber );
      }

    其中:dataGridTableStyle1 为此窗体类的TableStyles实例.

    再在构造函数或窗口的OnLoad中加入方法 InIt() 的调用即可.

    结果如图:

    按此在新窗口打开图片

  • 相关阅读:
    DNS隧道
    记录上锁(fcntl)
    posix对线程的调整
    MySQL创建存储过程
    MySQL的WHERE语句中BETWEEN与IN的用法和他们的区别
    mysql中distinct
    线程的工作方式-流水线
    可执行程序的生成过程
    线程高级编程
    time函数及其用法
  • 原文地址:https://www.cnblogs.com/HD/p/293583.html
Copyright © 2011-2022 走看看