AntonioRodrigo
asked on
ComboBox selected text position changes after selected item change
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_SelectedIndexCha nged(objec t sender, EventArgs e)
{
comboBox3.SelectionStart = 0;
comboBox3.SelectionLength = 0;
}
Any idea?
Greetins, Frenky
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_SelectedIndexCha
{
comboBox3.SelectionStart = 0;
comboBox3.SelectionLength = 0;
}
Any idea?
Greetins, Frenky
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.