Solved

ComboBox selected text position changes after selected item change

Posted on 2011-09-30
4
478 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

696 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