如何在WPF中使用DataGrid的等效替代代码 [英] How to Equivalent Alternate Code for DataGrid in WPF

查看:106
本文介绍了如何在WPF中使用DataGrid的等效替代代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过这段代码但没有在WPF中得到答案。如何在WPF的DataGrid中对此进行编码



private void更改(字符串id,int current)

{

dataGridView.Rows [this.GetRowIndex(id)]。Cells [8] .Value =(object)current;

}



private int GetRowIndex(string ID)

{

int num = -1;

foreach(DataGridViewRow dataGridViewRow in(IEnumerable)this.dataGridView。行)

{

if(dataGridViewRow.Cells [0] .Value.Equals((object)ID))

num = dataGridViewRow。索引;

}

返回num;

}

WPF datagridd的替代代码是什么?

I have Tried this code but not getting answer in WPF. How to code this in DataGrid of WPF

private void Change(string id, int current)
{
dataGridView.Rows[this.GetRowIndex(id)].Cells[8].Value = (object) current;
}

private int GetRowIndex(string ID)
{
int num = -1;
foreach (DataGridViewRow dataGridViewRow in (IEnumerable) this.dataGridView.Rows)
{
if (dataGridViewRow.Cells[0].Value.Equals((object) ID))
num = dataGridViewRow.Index;
}
return num;
}
What is the alternative code for WPF datagridd?

推荐答案

WPF使用路由事件 [ ^ ]。编程技术有点不同,但你没有说明你有什么样的问题。

这是 DataGrid事件 [ ^ ]。我没有看到更改事件;(



请看一下类似的问题: WPF数据网格中的行单击事件 [ ^ ]。我希望它能帮助你理解如何捕捉到点击事件。
WPF uses routed events[^]. The technic of programming is bit different, but you did not specified what kind of issue do you have.
Here is a collection of DataGrid events[^]. I don't see Change event ;(

Please, have a look at similar question: Row click event in WPF datagrid[^]. I hope it help you understand how to catch a "click" event.


这篇关于如何在WPF中使用DataGrid的等效替代代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆