Solved

ComboBox selected text position changes after selected item change

Posted on 2011-09-30
4
469 Views
Last Modified: 2012-05-12
Hello,

I am using Windows Forms. I have a problem with ComboBox, selected text. My problem was, that text of some items was longer than the combo box -> I've solved this with properties:

myCombo.SelectionStart = 0
myCombo.SelectionLength = 0

That works OK for the first item. Of course, I don't see whole text, but at least I see text of the item from the start, which is good enough. But, if I select some other item from the combo box and it's text is longer than the combo I see only the end of the text -> but I must see text from the start.

I've also tried to catch SelectedIndexChanged event and re-set properties, without success:

        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBox3.SelectionStart = 0;
            comboBox3.SelectionLength = 0;
        }


Any idea?


Greetins, Frenky
0
Comment
Question by:AntonioRodrigo
4 Comments
 
LVL 6

Accepted Solution

by:
kswathi earned 167 total points
ID: 36890791
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 167 total points
ID: 36891137
0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 166 total points
ID: 36892522
Depending on the data you use and what you do with it, you could also modify the text in the source with a Substring command so that it is not too long.
0
 

Author Comment

by:AntonioRodrigo
ID: 36901946
Thanks for answers.

I've managed to solve the problem, but not 100%. I put

comboBox.SelectionStart = 0;
comboBox.selectionLength = 0;

on key up and mouse over events. Default behaviour on selected item changed occurs every time - whole item is selected and you see only the end of it. WIth those two events, the selection is moved back to the start. Default behaviour cannot be overriden, but you can have affect on it after it happens.

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now