读书人

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

发布时间: 2011-12-15 23:41:24 作者: rapoo

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; } 

读书人网 >C#

热点推荐