ComboBox/DateTimePickerBox drop down arrow visible/invisible

Hello,

Is it possible to make the drop-down arrow of these Boxes invisible when they are out of focus, and visible when they are

Kind regards,

-------------------------------------------------------------------------------------------------------------------------

This newbie can't talk and can't walk. Embarrassing.




Answer this question

ComboBox/DateTimePickerBox drop down arrow visible/invisible

  • Jeff Brown

    It is possible if dealing with a DataGridViewComboBoxColumn by setting the DisplayStyleForCurrentCellOnly property. It is not possible for standard ComboBoxes.

    Another alternative to consider would be using a simple TextBox with an AutoComplete source. You may be able to create a custom user control combining a TextBox with a button (with a dropdown arrow icon) and dynamically hiding and showing the button on TextBox focus. The "drop down" list coming from the AutoComplete source.

    Jim Wooley
    http://devauthority.com/blogs/jwooley/default.aspx



  • JohnKelley32

    Here is a crude - from newbie to newbie - solution:

    Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Private Sub ComboBox1__Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.Enter

    TextBox1.Visible = False

    End Sub

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Private Sub ComboBox1_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.Leave

    TextBox1.Visible = True

    End Sub

    End Class

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    To test: 1. Place one ComboBox into your form. 2.Place two TextBox into your form. 3. Drag and reduce the size of TextBox1 to fit over the 'arrow square' of the ComboBox.



  • Topher

    No, the Windows combobox control doesn't have a message for that. Good thing, it would be pretty confusing to the user to have to click on the edit box first before they can drop down the list of choices...



  • road runner

    Hello,

    Bad formulated question.

    Take for example the "ComboBox" Properties Window in Design View. There are several such fields under the "Appearance", "Behaviour", "Data", "Design" "Focus" "Layout" and "Misc" sections which follow the algorithm: the -arrow in a box-is not visible until a Click on is on perfomed on the field.

    Kind regards,



  • Jia Li MSFT

    Hello Jim,

    You said: "create a custom user control....." This engendered the idea that instead of TextBox resize (fumbling around), use a picture.

    Private Sub ComboBox1__Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.Enter

    PictureBox1.Visible = False

    End Sub

    Private Sub ComboBox1_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.Leave

    PictureBox1.Visible = True

    End Sub

    Kind regards,

    ----------------------------------------------------------------------------------------------------------------------------------------

    This newbie can't talk and can't walk. Embarrassing.



  • vaio pcgk33

    Nice "out-of-the-box" thinking solution! Use a Panel control to blend with the form's background.



  • ComboBox/DateTimePickerBox drop down arrow visible/invisible