资讯   |   开发   |   选机中心   |   产品大全 | IBM | 惠普 | 联想 | 戴尔 | 苹果 | 神舟
更多: | 华硕 | 明基 | 方正 | 紫光 | TCL | 夏新 | 联宝 | 宏碁 | 七喜 | 长城 | 清华同方 | 海尔 | 三星 | 东芝 | 索尼 | 富士通 | LG | 技术 | ddnoon
当前位置:笔记本 > 软件开发 >
Advertisement
文章正文

立即结贴:请问在DataGrid控件中,双击如何取得当前行中每一列的值,谢谢!

类型:转载   责任编辑:asp.net   日期:2007/05/23


热门软件下载:


   

请问在DataGrid控件中,双击如何取得当前行中每一列的值,谢谢!

网友回答:

发表者:ssun1999

 
          Private   Sub   DataGrid1_DoubleClick(ByVal   sender   As   Object,   ByVal   e   As   System.EventArgs)   Handles   DataGrid1.DoubleClick  
   
      Dim   s   As   String  
                                                s   =   DataGrid1.CurrentCell.RowNumber当前行号  
                          msgbox(   DataGrid1.Item(s,   1))  
  End   sub

发表者:ssun1999

msgbox(   DataGrid1.Item(s,   1))1代表列号

发表者:Uncommon

protected   void   Grid_CurCellChange(object   sender,   EventArgs   e)  
  {  
        string   myString   =   "CurrentCellChanged   event   raised,   cell   focus   is   at   ";  
        string   myPoint     =   myDataGrid.CurrentCell.ColumnNumber   +   ","   +  
                                      myDataGrid.CurrentCell.RowNumber;  
        myString   =   myString   +   "("   +   myPoint   +   ")";  
        MessageBox.Show(myString,   "Current   cell   co-ordinates");  
  }  
 

发表者:tl_pear

Private   Sub   DataGrid1_DoubleClick(ByVal   sender   As   Object,   ByVal   e   As   System.EventArgs)   Handles   DataGrid1.DoubleClick  
          Dim   drv   As   DataRowView   =   CType(Me.BindingContext(Me.datagrid.DataSource).Current,           DataRowView)  
          dim   i   as   integer  
          for   i=0   to   datagrid.Columns.Count-1  
                msgbox(cstr(drv(i)))  
          next   for  
  end   sub

发表者:tl_pear

在DataGrid1_CurrentCellChanged事件中添加代码:  
  Private   Sub   DataGrid1_CurrentCellChanged(ByVal   sender   As   Object,   ByVal   e   As   System.EventArgs)   Handles   DataGrid1.CurrentCellChanged  
   
                  Me.DataGrid1.Select(Me.BindingContext(Me.datagrid1.DataSource).Position)  
  ’在网格中任何地方点击都会选中这一行。  
          End   Sub  
 


 

 
热门推荐笔记本: IBM笔记本
相关文章:
webmaster:popbb@126.com   最佳浏览:1024X768 MSIE
©2007 popbb.net All Rights Reserved