在combobox选择更改事件中需要帮助 [英] Need help in combobox selection change event

查看:56
本文介绍了在combobox选择更改事件中需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



在我的应用程序中,我有一个组合框和一个文本块

i已添加3项conbobox decimal,piece和打开



现在我想要的是当我从下拉列表中选择十进制时,它应该将文本块内容更改为十进制。就像这一块和十几个一样。



请告诉我该怎么办,因为我对此非常陌生。

这是我的代码,但它不起作用..



Hi all

In my application i have one combo box and one textblock
i have added 3 items in conbobox decimal, piece and dozen

Now i want is when i select decimal from the dropdown, it should change the textblock content to decimal..like this for piece and dozen.

Please tell me how to do as i am very much new to this.
this is my code but it's not working..

If cmbUnit.selectedvalue.tostring="Decimal" Then
   textblock1.text="Decimal"
ElseIf cmbUnit.selectedvalue.tostring="Pieces" Then
   textblock1.text="Pieces"





谢谢你



Thank you

推荐答案

你好,


Combobox1_SelectIndexChanged 事件上的
写下这段代码:



Hi,

on the Combobox1_SelectIndexChanged event write this code:

TextBox1.text = Combobox1.Text


在XAML中

In the XAML
<textblock x:name="textblock1" text="{Binding ElementName=cmbUnit, Path=SelectedItem}" xmlns:x="#unknown" />





我可能有一些上层和下层错误,但应该是这样的。然后,当您的组合框更改所选项目时,文本块应自动更新。



I might have some of the upper and lowercases wrong, but it should be something like that. Then when your combo box changes the selected item the textblock should automatically update.


试试这个:



Try this:

Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
    If ComboBox1.SelectedIndex = 0 Then
        TextBox1.Text = "DECIMAL"
    ElseIf ComboBox1.SelectedIndex = 1 Then
        TextBox1.Text = "PIECES"
    ElseIf ComboBox1.SelectedIndex = 2 Then
        TextBox1.Text = "DOZEN"
    End If
End Sub


这篇关于在combobox选择更改事件中需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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