zoukankan      html  css  js  c++  java
  • [开发手记] 如何取到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.

  • 相关阅读:
    P1312 [NOIP2011 提高组] Mayan 游戏
    Codeforces Round 736
    CF487E Tourists
    荏苒
    数论
    [NOI2009] 二叉查找树 题解
    元素
    线性基
    杂录
    SQL中关于Join、Inner Join、Left Join、Right Join、Full Join、On、 Where区别
  • 原文地址:https://www.cnblogs.com/anytao/p/682520.html
Copyright © 2011-2022 走看看