如何获得组合框Silverlight中的selectetd值 [英] How to get the selectetd value in combobox silverlight

查看:68
本文介绍了如何获得组合框Silverlight中的selectetd值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai ...我在项目框集合中添加了一些项目。如果我在组合框中选择项目,我想获得Selected值,请帮我下面是我的代码





XAML代码



  <   ComboBox    高度  =  23    Horizo​​ntalAlignment   =    保证金  =  346,193, 0,0   名称  =  CmbBank    VerticalAlignment   =  Top   宽度  =  120    ItemsSource   =  {Binding} >  
< ; ComboBoxItem 内容 < span class =code-keyword> = ICICI BANK / >
< ComboBoxItem 内容 = IDBI BANK / >
< ComboBoxItem 内容 = HDFC BANK / >
< ComboBoxItem 内容 = INDIAN BANK / >
< ComboBoxItem 内容 = 印度海外银行 / >
< ComboBoxItem 内容 = SBI / >
< / ComboBox >





我的XAML.cs代码

string strBranch = CmbBan k.SelectedValue.ToString();

解决方案

您好,



在您的情况下,SelectedValue将是ComboBoxItem。要获取内容,请使用以下代码段。



  string  strBranch =((ComboBoxItem) this  .CmbBank.SelectedValue).Content.ToString(); 





希望它有所帮助..

谢谢,

Kannan。小号


Hai... i am add some item in item box collection .if i select the item in combo box,i want to get the Selected value please help me below is my code


XAML Code

<ComboBox Height="23" HorizontalAlignment="Left" Margin="346,193,0,0" Name="CmbBank" VerticalAlignment="Top" Width="120" ItemsSource="{Binding}">
                <ComboBoxItem Content="ICICI BANK" />
                <ComboBoxItem Content="IDBI BANK" />
                <ComboBoxItem Content="HDFC BANK" />
                <ComboBoxItem Content="INDIAN BANK" />
                <ComboBoxItem Content="Indian Overseas Bank" />
                <ComboBoxItem Content="SBI" />
            </ComboBox>



my XAML.cs code
string strBranch=CmbBank.SelectedValue.ToString();

解决方案

Hi,

In your case the SelectedValue will be the ComboBoxItem. To get the content, use the below code snippet.

string strBranch=((ComboBoxItem)this.CmbBank.SelectedValue).Content.ToString();



Hope it helps..
Thanks,
Kannan. S


这篇关于如何获得组合框Silverlight中的selectetd值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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