我创建了具有lookupedit和texedit的lyaout控件
LayoutControl lc = new LayoutControl();
lc.Dock = DockStyle.Top;
LookUpEdit steelstandard = new LookUpEdit();
steelstandard.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;
steelstandard.Properties.DataSource = assembly.GetSteelStandard();
steelstandard.Properties.DisplayMember = "Norme";
steelstandard.Properties.ValueMember = "id";
steelstandard.Properties.ShowHeader = false;
steelstandard.EditValue = 1;
TextEdit tolerance = new TextEdit();
tolerance.ReadOnly = true;
lc.AddItem(Resources.standard, steelstandard).TextVisible = true;
lc.AddItem(Resources.tolerance, tolerance).TextVisible = true;
this.Controls.Add(lc);
this.Dock = DockStyle.Fill;
lc.BestFit();
并且我使用此代码为textedit控件赋值
int length = Convert.ToInt32(rowGridView1["Long mm"]);
if (Convert.ToInt32(steelstandard.EditValue) == 1)
{
tolerance.Text = ((length / 5000) + 2).ToString();
}
else
{
tolerance.Text = ((length / 10000) + 2).ToString();
}
代码运行正常,但是当lookupedit值更改时,什么都没发生,我尝试使用此代码
private void steelstandard_EditValueChanged(object sender, EventArgs e)
{
tolerance.Refresh();
}
但还是没有
当lookupedit值更改时如何捕捉,以便可以为textedit分配新值
答案 0 :(得分:0)
此代码解决了我的问题
void steelstandard_EditValueChanged(object sender, EventArgs e)
{
int[] selectedRows = gridView1.GetSelectedRows();
for (int i = 0; i < selectedRows.Length; i++)
{
DataRow rowGridView1 = (gridView1.GetRow(selectedRows[i]) as DataRowView).Row;
int length = Convert.ToInt32(rowGridView1["Long mm"]);
if (Convert.ToInt32(steelstandard.EditValue) == 1)
{
tolerance.Text = string.Empty;
tolerance.Text = ((length / 5000) + 2).ToString();
}
else
{
tolerance.Text = string.Empty;
tolerance.Text = ((length / 10000) + 2).ToString();
}
}
}
steelstandard.EditValueChanged += steelstandard_EditValueChanged;