Solved

ComboBox selected text position changes after selected item change

Posted on 2011-09-30
4
466 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

19 Experts available now in Live!

Get 1:1 Help Now