• [开发手记] 如何取到DataGrid某一行某一列的值


    发布日期:2007.3.21 作者:Anytao

    ©2007 Anytao.com 转贴请注明出处,留此信息。

     

    本文将介绍以下内容:

    • DataGrid的简单用法

     

    在WebForm开发时:dg.Items[i].Cells[j].Text.ToString();

    在WinForm开发时:dg[i,j];

    所以在dg的CurrentCellChanged中添加如下代码,就可以获得想要

    的当前行当前列的值

    当前行dg.CurrentCell.RowNumber;

    当前列dg.CurrentCell.ColumnNumber;

      private void dgShow_CurrentCellChanged(object sender, System.EventArgs e)
      {
       //点击DataGrid时,获取相应的网址给strUrl//

       strUrl=(string)dgShow[dgShow.CurrentCell.RowNumber,1];  //取得当前行,第2列的字段值

       btnOpenUrl.Enabled=true;
       lblUrl.Visible=true;
       lblUrl.Text=strUrl;

      }

     

    备注:该贴原发表于2006.4.14日我的CSDN Blog。

     

    ©2007 Anytao.com 转贴请注明出处,留此信息。

    本贴子以现状提供且没有任何担保,同时也没有授予任何权利。
    This posting is provided "AS IS" with no warranties, and confers no rights.

  • 相关阅读:
    如何提高完成端口的性能
    我回来了
    减少资源包中的图片,提高效率
    新的MOVE结构,和在项目中实际的感受
    截图小结
    本周小记
    css选择器
    CSS的三种引入方式
    A标签的四个伪类(L V H A)排序上的讲究
    关于CSS清理浮动的方法
  • 原文地址:https://www.cnblogs.com/anytao/p/682520.html
Copyright © 2020-2023  润新知