|
 |
|
เมื่อเลือกข้อมูลใน combobox แล้ว หลังจากนั้น ให้แสดงข้อมูลอื่นๆ ใน textbox |
|
 |
|
|
 |
 |
|
Code (C#)
private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
{
try
{
textBox1.Text = comboBox1.SelectedValue.ToString();
}
catch { }
}

หรือผูก textbox เข้ากับ BindingSource เดียวกับ comboBox1
TextBox
Code (C#)
this.cbIDTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.tblCarbrandBindingSource, "cbID", true));
comboBox
Code (C#)
this.comboBox1.DataSource = this.tblCarbrandBindingSource;
this.comboBox1.DisplayMember = "cbName_1";
this.comboBox1.ValueMember = "cbID";
แบบนี้

หลักการนี้สามารถใช้ได้กับหลายๆ control แถมยังลดการเขียนโค้ดได้อีกเยอะเลย
|
 |
 |
 |
 |
Date :
2017-04-25 12:47:26 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มีของ vb.net ไหมครับ ฐานข้อมูลเป็นaccessเหมือนกัน
|
 |
 |
 |
 |
Date :
2019-03-25 19:24:17 |
By :
ืZhang |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|