首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

DataGridView下标的有关问题(超级不理解)

2011-12-15 
DataGridView下标的问题(超级不理解)单击的那行数据添加到相应的文本框中private void DbgStockPlan_CellC

DataGridView下标的问题(超级不理解)
单击的那行数据添加到相应的文本框中 
private void DbgStockPlan_CellClick(object sender, DataGridViewCellEventArgs e)(Click事件也试过效果一样)
  {
  int i = this.DbgStockPlan.CurrentCell.RowIndex;
  (int i= this.DbgStockPlan.CurrentRow.Index; 也试过效果一样)
  if (i >= 0)
  {
  this.TxtID.Text = this.DbgStockPlan[1, i].Value.ToString();
   
  this.TxtCount.Text = this.DbgStockPlan[2, i].Value.ToString();

  }
  }
表里数据为 
申请编号 材料编号 数量 用途 备注 材料名 
P20082152243 W12 123 fdsa fsa 方便面 

事件过后 
this.TxtID.Text 的值为 fsa 
this.TxtCount.Text 的值为 方便面 

太奇怪了`` 
能找的地方都找过了`` 
不知道问题出在哪

[解决办法]

C# code
DataGridView.Item 属性 (String, Int32) public DataGridViewCell this [    string columnName,    int rowIndex] { get; set; } 

热点排行