Home All Groups Group Topic Archive Search About

Combo box to start at first character after user selects

Author
29 Nov 2006 4:24 PM
Mike OKC
The text in my combo box is longer than the control can show, when I click on
the down arrow, I can see the whole text, but when I select one of the items,
the text box of the combo box shows the end of the text. Due to limited room
I can not expanded the combo box control, so I want to show the front of the
text and not the default back of the text when a user selects a value.

Currently the user selects from the combo box, then has to hit the "home"
key to see the beginning of the text.

Author
30 Nov 2006 1:51 AM
Kevin Yu [MSFT]
Hi Mike,

To make the cursor scroll to the first character of the line, we can
simulate pressing the Home key. We just send a key press message to the
control using SendKeys class. Here is an example.

    Private Sub ComboBox1_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles ComboBox1.TextChanged
        SendKeys.Send("{HOME}")
    End Sub

If anything is unclear, please feel free to let me know.

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Author
1 Dec 2006 5:42 PM
Mike OKC
I get the error message, "SendKeys cannot run inside this application because
the application is not handling Windows messages. Either change the
application to handle messages, or use the SendKeys.SendWait method."

What does that mean?

Show quoteHide quote
"Kevin Yu [MSFT]" wrote:

> Hi Mike,
>
> To make the cursor scroll to the first character of the line, we can
> simulate pressing the Home key. We just send a key press message to the
> control using SendKeys class. Here is an example.
>
>     Private Sub ComboBox1_TextChanged(ByVal sender As System.Object, ByVal
> e As System.EventArgs) Handles ComboBox1.TextChanged
>         SendKeys.Send("{HOME}")
>     End Sub
>
> If anything is unclear, please feel free to let me know.
>
> Kevin Yu
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ==================================================
>
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>
Author
4 Dec 2006 4:29 AM
Kevin Yu [MSFT]
Hi Mike,

Could you let me know what kind of application you're working on? Is it a
windows form app?

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Author
4 Dec 2006 7:39 PM
Mike OKC
Yes, it is a win form app, VB 2003.



Show quoteHide quote
"Kevin Yu [MSFT]" wrote:

> Hi Mike,
>
> Could you let me know what kind of application you're working on? Is it a
> windows form app?
>
> Kevin Yu
> Microsoft Online Community Support
> ==================================================
>
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>
Author
5 Dec 2006 6:38 AM
Kevin Yu [MSFT]
Hi Mike,

In VB2003, try to handle the SelectedIndexChanged event like the following:

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        SendKeys.Send("{HOME}")
    End Sub

Does this working on your machine?

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)