基于必须更改文本框值的组合框选择 [英] On combobox selection based on that the textbox value must get change

查看:83
本文介绍了基于必须更改文本框值的组合框选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个项目,因为我可能会卡住,我需要一个解决方案
当我选择组合框值时,必须根据sql server 2008r2更改文本框vzlue
请回复
如果您能解决我的问题,我将不胜感激

[edit]紧急情况已删除-OriginalGriff [/edit]

I am doing a project in that i could stuck i need a solution
when i select combobox value the textbox vzlue must change based on sql server 2008r2
plz do reply
i would be thankful if u solve my problem

[edit]Urgency deleted - OriginalGriff[/edit]

推荐答案

它是Windows还是Web应用程序?之后请附上您的代码

如下所示,在Combobox事件中编写代码(为Textbox分配值).
Is it a Windows or web application? Here after come with your code

Write the code(Assign the value for the Textbox) in Combobox event like below.
eventname()
{
  //value to Textbox
}


如果它是Web应用程序,则需要为Combobox(Dropdownlist.)设置Autopostback=True


If it''s a web application then you need to set Autopostback=True for Combobox(Dropdownlist.)


这取决于您的操作方式.
如果使用BindingSource加载组合框,则将DisplayMember设置为在组合框中显示的适当字段,并将ValueMember设置为文本框中所需的字段.
处理ComboBox SelectedIndexdChanged事件,并设置文本:
It depends on how you do it.
If you are using a BindingSource to load the combobox, then set the DisplayMember to the appropriate field for display in the combobox, and the ValueMember to the field you want in the textbox.
Handle the ComboBox SelectedIndexdChanged event, and set the text:
private void MyComboBox_SelectedIndexChanged(object sender, EventArgs e)
    {
    MyTextBox.Text =  MyComboBox.SelectedValue.ToString();
    }


(您可能想在其中进行一些错误检查,但这使您有了主意)


(You may want to put some error checking in there, but that gives you the idea)


这篇关于基于必须更改文本框值的组合框选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆