CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2011
    Location
    Buenos Aires, Argentina
    Posts
    130

    Post ComboBox RightToLeft and TextAlign

    Hi, I'm playing around with a combobox and having a little issue with the items in it.

    I intend for the CB to be just the size of the down-arrow, and to expand (the size, not the pulldownitems) itself on mouse_enter event. That works fine, but for the standart default CB, the down-arrow would move to the far right end of the control when I resize it on mouse_enter. So I would need to move the mouse to the end to click on the arrow and open it's items.

    Now, I found out that the RightToLeft = Yes property will make the down-arrow stay on the far left side of the control when resizing, but at the cost of my strings being... em, RightToLefted...?
    So I thought omg I'm so much smarter than you, I'll just invert my string!! Big surprise when I found out that for my string it always gave the same result!
    For example:
    Code:
    string sample = intVariable.ToString("00") + " times";
    this.cbSampleBox.Items.Add(sample);
    
    and
    
    string sample = "times " + intVariable.ToString("00");
    this.cbSampleBox.Items.Add(sample);
    
    will both add an item with text "times 01"
    However
    Code:
    string sample = "every " + intVariable.ToString("00") + " times"; // works
    string sample = "- " + intVariable.ToString("00") + " times"; // doesn't
    Maybe RightToLeft will perform more analisys on the string and apply cultural formats?

    MSDN RightToLeft article says that only text alignment for CBs will be affected, but little about how the strings are to be treated.
    Not that I'm going into any developers crisis, but I just found it curious... If only I'd have a .TextAlign property!

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: ComboBox RightToLeft and TextAlign

    Maybe this article will help you :

    Extending the ComboBox with C#
    http://www.codeguru.com/csharp/cshar...cle.php/c15261

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured