R J

R J

  • NA
  • 380
  • 70.7k

How to get superscript text in Combobox

Aug 4 2011 10:33 AM

 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


Answers (5)

0
Vulpes

Vulpes

  • 0
  • 96k
  • 2.6m
Aug 4 2011 3:00 PM
I've just tried the code but nothing disappeared when I selected the first or second items in the ComboBox - both items were still there when I clicked to open the drop-down list.

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.
0
R J

R J

  • 0
  • 380
  • 70.7k
Aug 4 2011 11:34 AM
Hi can u please solve this issue.
0
R J

R J

  • 0
  • 380
  • 70.7k
Aug 4 2011 11:30 AM
Hi thanks for reply.

 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.






0
Vulpes

Vulpes

  • 0
  • 96k
  • 2.6m
Aug 4 2011 10:46 AM
Check out WPF's support for Open Type fonts:

http://msdn.microsoft.com/en-us/library/ms745109.aspx
0
Zoran Horvat

Zoran Horvat

  • 0
  • 4.5k
  • 747.4k
Aug 4 2011 10:40 AM
ComboBox does not provide such functionality. Some effects can be achieved using Unicode characters for x^2, x^3, but that is the end of it.

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