编辑数据网格视图的列标题
本文关键字:标题 视图 网格 数据 数据网 编辑 | 更新日期: 2024-10-23 12:12:43
伙计们,我需要在一个组合框中获得我的数据网格视图的所有标题,然后在从组合框中进行选择时,我会在一个文本框中获得标题,当我在文本框中修改时
1.我在组合框中得到了修改后的标题。
2.我在datagridview中也得到了修改后的头。
我做了以下
//fill in the combobox with the ACTUAL headers of the list box.
for (int i = 0; i <= listselected.columns.Count(); i++)
{
comboedit.Items.Add(listselected.gridview.Columns[i].HeaderText);
comboedit.SelectionChanged += (sende, eee) =>
{
//on user selection, display choice in textbox for editing
textedit.Text = comboedit.SelectedItem.ToString();
};
}
textedit.TextChanged += (sende, eee) =>
{//display EDITED text as header of the list box
listselected.gridview.Columns[comboedit.SelectedIndex].HeaderText = textedit.Text;
};
然而,在这段代码中,我在datagridview中只得到了修改后的头,组合框没有更新。
我应该如何修改代码以执行我想要的操作?
要更新组合框文本,请尝试此
comboedit.SelectedItem.Text = textedit.Text;
在中
textedit.TextChanged += (sende, eee) =>