如何在vb.net中单击组合框项时更新文本框项 [英] How to update textbox item when click combo box item in vb.net

查看:98
本文介绍了如何在vb.net中单击组合框项时更新文本框项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

单击组合框项后,我在更改文本框中的项目时遇到问题。我在表格设备中添加了像设备ID,设备项目(组合框),模型(组合框),数量,序列号和状态等项目。我希望在编辑equipmentItem(组合框)后,项目状态(文本框)自动从可用变为不可用。任何人都可以帮助我??

I have a problem to change already item in textbox after click combo box item. I add item like equipmentID,equipmentItem(combobox),model(combobox),quantity, serialnumber and status in form Equipment. I want item status(textbox) change automatic from available to unvailable after edit the equipmentItem(combobox). Anybody can help me??

推荐答案

您可以在VB代码后面的组合框中使用SelectedIndexChanged事件。在此事件中添加代码以更改文本框。



您还必须确保组合框的AutoPostBack属性设置为True。这样一旦组合框改变,页面将回发并且SelectedIndexChanged事件中的代码将运行。



祝你好运!



更新日期:2013年2月27日

AutoPostBack属性不在VB代码中。您可以通过单击设计器中的组合框找到它,然后查看属性窗口。您也可以直接在ASP.NET代码中更改它。这样的事情:



You can use the SelectedIndexChanged event for the combobox in the VB code behind. Add code in this event to change the textbox.

You will also have to be sure the AutoPostBack property of the combobox is set to True. This way whenever the combobox is changed, the page will postback and the code in the SelectedIndexChanged event will run.

Good luck!

Update: 27 Feb 2013
The AutoPostBack property is not in the VB code. You can find it by clicking on the combobox in the designer and then looking in the properties window. You can also change it directly in the ASP.NET code. Something like this:

<asp:DropDownList ID="SomeComboBox" runat="server" AutoPostBack="True"></asp:DropDownList>





那么您将需要代码来更改VB代码中SelectedIndexChanged事件中的文本框。这样的事情:





Then you will need code to change the textbox in the SelectedIndexChanged event in the VB code. Something like this:

Private Sub SomeComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles SomeComboBox.SelectedIndexChanged
   'Code to change textbox here
   If SomeTextBox.Text = "available" Then SomeTextBox.Text = "unavailable"
End Sub


这篇关于如何在vb.net中单击组合框项时更新文本框项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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