【问题标题】:how to get the rows property in gridview of devxpress with a button to edit?如何使用编辑按钮在devexpress的gridview中获取rows属性?
【发布时间】:2022-10-04 20:42:30
【问题描述】:
我有一个带有 devexpress 的 gridview 我的 gridview 包含一个 id ID=\"GriviewLV1\" 并且我在 gridview 的行中有一个按钮来编辑记录,如果单击按钮我试图在按钮中单击以进行编辑但无法获取属性行或类似的东西。我正在尝试这样的事情,但不能做行属性,因为在网格视图 devexpress 中不存在行属性
button_Edit_click(object sender, EventArgs e)
{
foreach (GridViewRow row in GriviewLV1.Rows)
{
}
}
标签:
c#
asp.net
devexpress
【解决方案1】:
你到底需要什么行集合?
据我所知,您只能使用记录(DataSource 属性对象)进行操作。也可以获得选定的行。我的一些带有解释的代码示例:
private List<ImageSetMember> imageSets;
...
//assign collection as grid's DataSource.
//From now on any actions on imageSets object will be automatically reproduced
//as grid's row changes.
imageSetGridControl.DataSource = imageSets;
...
private void replaceButtonEdit_Click(object sender, System.EventArgs e)
{
//get focused row record's index at DataSource collection
int index = imageSetGridView.GetDataSourceRowIndex(imageSetGridView.FocusedRowHandle);
var selectedImage = imageSet[index].Image; //accessing to row's record
}