Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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

XML
<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();
Posted
Updated 31-May-13 22:07pm
v2
Comments
AlphaDeltaTheta 2-Jun-13 22:12pm    
So, you got the answer??

1 solution

Hi,

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

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


Hope it helps..
Thanks,
Kannan. S
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900