Hi can any body please suggest me how to assign superscript text to combo box item.
My Combo box is having some items, now i need to add superscript text to each item dynamically.
Appreciate if some body helps.
regards
J. R
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Aug 4, 2011, 3:00 PM
Are you perhaps saying that you want the ComboBox to remain open immediately after an item has been selected? If you are, then I'd use a ListBox instead.
R JPosted Aug 4, 2011, 11:34 AM
R JPosted Aug 4, 2011, 11:30 AM
I have written the code in c sharp like this.
PopulateCombo(){
myCombo.Items.Add(GetWithTradeMark("Disability Insurance"));
MyCombo.Items.Add("Life insurance");
}
//return type textblock
GetWithTrademark(string text){
TextBlock txtBlk = new TextBlock();
Run rnText= new Run();
rnText.text = text;
txtBlk.Inlines.Add(rnText);
Run sptext = new Run();
sptext.Text = " SM";
sptext.FontSize = 8;
sptext.BaselineAlignment = System.Windows.BaselineAlignment.TextTop;
textBlk.Inlines.Add(sptext);
return textBlk;
}
The combo box is showing properly the text and its superscript. But As this combo item consists of textblock, so OnComboSelectionChangedEvent, once if we selected first item and again if we select second item, then first item is disappearing from combo box. i am unable to figure out the issue.
Could some body please help me.
VulpesPosted Aug 4, 2011, 10:46 AM
http://msdn.microsoft.com/en-us/library/ms745109.aspx
Zoran HorvatPosted Aug 4, 2011, 10:40 AM
You can mimic the behaviour by providing your own Paint event handler, but that is harder than to develop custom ComboBox control. However, creating your own ComboBox control is not so hard task.
Some intermediate solution can be to relax requirements. For example, x^(got something to say) can be written as x [got something to say]. As long users accept such format, it could prove to be good.
Zoran