如何更改选择c#动态使用c#(not xaml)中的Binding()更改combobox值 [英] How to update combobox value on changing selection c# dynamically using Binding() in c# (not xaml)

查看:452
本文介绍了如何更改选择c#动态使用c#(not xaml)中的Binding()更改combobox值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是c#silverlight5初学者,我有一个情况,我必须使用c#动态创建一个组合框,并保留项目。但是现在当我运行它运行正确显示最后一个值默认情况下,但是当我选择另一个值,它不更新在附近的文本框中的值,因为它不工作动态。

I am c# silverlight5 beginner and i have a situation that i have to created a combo box dynamically using c# and kept items in it. But the problem now when i run it run properly showing the last value by default but when i select the another value it don't update the that value in the text box near by because it is not working dynamically.

我想我需要添加一些选择改变或一些其他事件使用c#。但我不知道如何做到这一点。请注意,我使用c#只创建了这个组合框。

I guess i need to add some selection changed or some other event using c#. But i dont know how to do that. Please note that i have created this combo box using c# only.

如何将对应的值更改为combobox值? / strong>

How to change the value in correspondng selection to the combobox value ?(just using c#)

推荐答案

最后,我使用 SelectionChanged 创建 SelectionChangedEventHandler
代码如下(可能对一些未来用户有用):

At last i have done it using SelectionChanged and creating SelectionChangedEventHandler. The code is as below (may be useful for some future user):

cb.SelectionChanged + = new SelectionChangedEventHandler(comboBox1_SelectionChanged) ; in convert()函数和外部转换器函数:

cb.SelectionChanged += new SelectionChangedEventHandler(comboBox1_SelectionChanged); in converter() function and outside converter function :

 void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        txtblk2.Text = cb.SelectedValue.ToString() + " millions";
    }

这篇关于如何更改选择c#动态使用c#(not xaml)中的Binding()更改combobox值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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