为什么在存储库组合框中选择一个新值但无法在网格控件中获取它?
你好,我有一个网格控件,它包括三列:column1、column2和column 3。Column2和Column3是存储库comboBox1和存储库comboBox2:repcomboBox 1有一个string类型list的数据源,repcomboBox2有一个int类型list的数据源。
我的网格控件也有一个数据源。
我希望实现以下功能:当在repcomboBox1中选择stringA时,repcomboBox2中的值将默认为intA。
我尝试以下代码:
private void repoCombo1_EditValueChanged(object sender, EventArgs e)
{
GridView view = gridControl1.FocusedView as GridView;
string format = gridView1.GetFocusedRowCellValue("field2Name").ToString();
if (format.Equals(stringA))
{
gridView1.SetRowCellValue(gridView1.FocusedRowHandle, view.Columns.ColumnByFieldName("field3Name"), intA);
}
}
例如,如果在 rowX 中,repcomboBox1 中的当前值为 stringB,我选择了 stringA 而不是 stringB,我调试代码并找到“ string format = gridView1.GetFocusedRowCellValue("field2Name").ToString() ;”将格式设置为“stringB”而不是我期望的“stringA”。如何获取存储库组合框中新选择的值?为什么它没有改变?多谢!
Hi I have a gridcontrol, which includes three columns: column1, column2 and column 3. Column2 and Column3 are repository comboBox1 and repository comboBox2: repcomboBox 1 has a data source of string type list and repcomboBox2 has a data source of int type list.
My grid control also has a data source.
I hope to implement the following function: when stringA is selected in repcomboBox1, the value in repcomboBox2 will be default to intA.
I try the following code:
private void repoCombo1_EditValueChanged(object sender, EventArgs e)
{
GridView view = gridControl1.FocusedView as GridView;
string format = gridView1.GetFocusedRowCellValue("field2Name").ToString();
if (format.Equals(stringA))
{
gridView1.SetRowCellValue(gridView1.FocusedRowHandle, view.Columns.ColumnByFieldName("field3Name"), intA);
}
}
For example, if in rowX the current value in repcomboBox1 is stringB, I selected stringA instead of stringB, I debug into the code and find " string format = gridView1.GetFocusedRowCellValue("field2Name").ToString();" set format as "stringB" other than "stringA" which I expect. How could I get the newly selected value in the repository comboBox? Why it doesn't change? Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,您应该使用以下代码:
You should use the following code for this purpose: