如何获得DevEx preSS XtraGrid中的选定行的值? [英] How to get the selected row values of DevExpress XtraGrid?

查看:412
本文介绍了如何获得DevEx preSS XtraGrid中的选定行的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑下面的图片

我得到在图中所示的三个文本框选定行的值当我使用以下code单击单元格。

I get the selected row values in the three textboxes shown in the figure when i click a cell using following code.

void dataGridView1_CellClick_1(object sender, DataGridViewCellEventArgs e) {
    TBGRNo.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
    TBSName.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
    TBFName.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
}

我的问题是:我怎么会做同样的事情在DevEx preSS XtraGrid中控制??

My Question is: how will I do the same thing in DevExpress XtraGrid control??

推荐答案

您可以通过多种方式做到这一点。您可以使用数据绑定(的InitializeComponent(后典型初始化);)

You can do this in a number of ways. You can use databinding (typical initialized after InitializeComponent();)

textBox1.DataBindings.Add(new Binding("Text", yourBindingSource, "TableName.ColumnName", true, DataSourceUpdateMode.OnPropertyChanged));

或使用DataLayoutControl(如果你要使用文本框进行编辑,我真的建议花一些时间来学习如何使用这个组件。

or use a DataLayoutControl (if you are going to use textbox for editing, I really recommend spending some time to learn how to use this component.

或FocusedRowChanged通过以下方法之一分配:

or in FocusedRowChanged by assigning from one of these methods:

textBox1.Text = gridView1.GetDataRow(e.FocusedRowHandle)["Name"].ToString();
textBox1.Text = gridView1.GetFocusedDataRow()["Name"].ToString();
textBox1.Text = (gridView1.GetFocusedRow() as DataRowView).Row["Name"].ToString();
textBox1.Text = gridView1.GetFocusedRowCellValue("Name").ToString();

这篇关于如何获得DevEx preSS XtraGrid中的选定行的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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