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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Zoran HorvatRank #792 · 2.9K reputationPosted Aug 4, 2011, 6:40 AM EDT
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
VulpesRank #55 · 29.2K reputationPosted Aug 4, 2011, 6:46 AM EDT
http://msdn.microsoft.com/en-us/library/ms745109.aspx
R J192 reputationPosted Aug 4, 2011, 7:30 AM EDT
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.
R J192 reputationPosted Aug 4, 2011, 7:34 AM EDT
VulpesRank #55 · 29.2K reputationPosted Aug 4, 2011, 11:00 AM EDT
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.