Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. Readonly ComboBox - Please give help?

Readonly ComboBox - Please give help?

Scheduled Pinned Locked Moved Windows Forms
csharpdesignhelpquestion
12 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V veeramani narayanasamy

    I need Readonly ComboBox in vb.net windows application, for this requirement i used to use textbox & combobox together in the same place. TextBox Properties ReadOnly=True TabStop=False ComboBox Properties AutoCompleteMode=SuggestAppend AutoCompleteSource=ListItems TabStop=True in ADD/EDIT events set ComboBox Enabled=True, if the event is done ComboBox Enabled=False this is my code Private Sub ComboBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.GotFocus TextBox1.Visible = False End Sub Private Sub ComboBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.LostFocus TextBox1.Visible = True End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged TextBox1.Text = ComboBox1.SelectedItem().ToString End Sub in design TextBox on top of the ComboBox, can see only the ComboBox Button. Please give me any simple solution for this....

    N.K.Veeramani Software Engineer InteriTech SDN. BHD., Malaysia

    M Offline
    M Offline
    Mycroft Holmes
    wrote on last edited by
    #2

    Your logic, at a form level, seems wrong. When you display the dialog you should know if CRUD is required at which point you display a combo so the user can edit the data. If the user is opening the form as RO then either disable the combo or display a textbox with the required value. I cheat, if the user does not have CRUD rights on the form/data I make the save button invisible/disabled. The user can do what they like, just can't save the results.

    V 2 Replies Last reply
    0
    • M Mycroft Holmes

      Your logic, at a form level, seems wrong. When you display the dialog you should know if CRUD is required at which point you display a combo so the user can edit the data. If the user is opening the form as RO then either disable the combo or display a textbox with the required value. I cheat, if the user does not have CRUD rights on the form/data I make the save button invisible/disabled. The user can do what they like, just can't save the results.

      V Offline
      V Offline
      veeramani narayanasamy
      wrote on last edited by
      #3

      thanks for the reply. i will tell why i need like this if i set ComboBox enabled=false the user can't the value clearly. thats-why i needed like that so how to solve this

      N.K.Veeramani Software Engineer InteriTech SDN. BHD., Malaysia

      M 1 Reply Last reply
      0
      • M Mycroft Holmes

        Your logic, at a form level, seems wrong. When you display the dialog you should know if CRUD is required at which point you display a combo so the user can edit the data. If the user is opening the form as RO then either disable the combo or display a textbox with the required value. I cheat, if the user does not have CRUD rights on the form/data I make the save button invisible/disabled. The user can do what they like, just can't save the results.

        V Offline
        V Offline
        veeramani narayanasamy
        wrote on last edited by
        #4

        I need Readonly ComboBox in vb.net windows application, for this requirement i used to use textbox & combobox together in the same place. TextBox Properties ReadOnly=True TabStop=False BackColor=Window ComboBox Properties AutoCompleteMode=SuggestAppend AutoCompleteSource=ListItems TabStop=True in ADD/EDIT events set ComboBox Enabled=True, if the event is done ComboBox Enabled=False - now the user can see the value clearly b'coz of textbox this is my code Private Sub ComboBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.GotFocus TextBox1.Visible = False End Sub Private Sub ComboBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.LostFocus TextBox1.Visible = True End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged TextBox1.Text = ComboBox1.SelectedItem().ToString End Sub in design TextBox on top of the ComboBox, can see only the ComboBox Button. Please give me any simple solution for this....

        N.K.Veeramani Software Engineer InteriTech SDN. BHD., Malaysia

        1 Reply Last reply
        0
        • V veeramani narayanasamy

          thanks for the reply. i will tell why i need like this if i set ComboBox enabled=false the user can't the value clearly. thats-why i needed like that so how to solve this

          N.K.Veeramani Software Engineer InteriTech SDN. BHD., Malaysia

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #5

          My point is why are you making the combo readonly. Simply disable the save button. If you insist on readonly then have a textbox on display when the form is in the view only mode and swap for a combo box on the add/edit event. If the act of entering the combobox changes the state of the form to edit mode then why are you bothering to have it readonly.

          A 1 Reply Last reply
          0
          • V veeramani narayanasamy

            I need Readonly ComboBox in vb.net windows application, for this requirement i used to use textbox & combobox together in the same place. TextBox Properties ReadOnly=True TabStop=False ComboBox Properties AutoCompleteMode=SuggestAppend AutoCompleteSource=ListItems TabStop=True in ADD/EDIT events set ComboBox Enabled=True, if the event is done ComboBox Enabled=False this is my code Private Sub ComboBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.GotFocus TextBox1.Visible = False End Sub Private Sub ComboBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.LostFocus TextBox1.Visible = True End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged TextBox1.Text = ComboBox1.SelectedItem().ToString End Sub in design TextBox on top of the ComboBox, can see only the ComboBox Button. Please give me any simple solution for this....

            N.K.Veeramani Software Engineer InteriTech SDN. BHD., Malaysia

            V Offline
            V Offline
            vaghelabhavesh
            wrote on last edited by
            #6

            I assume you want to make the combox box read only, so that user can't type in. For that try changing the DropDownStyle property to "DropDownList"

            Books are as useful to a stupid person as a mirror is useful to a blind person. - Chanakya

            M 1 Reply Last reply
            0
            • M Mycroft Holmes

              My point is why are you making the combo readonly. Simply disable the save button. If you insist on readonly then have a textbox on display when the form is in the view only mode and swap for a combo box on the add/edit event. If the act of entering the combobox changes the state of the form to edit mode then why are you bothering to have it readonly.

              A Offline
              A Offline
              Andy_L_J
              wrote on last edited by
              #7

              Someone :^) didn't like your answer... I'll pay you back :thumbsup:

              I don't speak Idiot - please talk slowly and clearly I don't know what all the fuss is about with America getting it's first black president. Zimbabwe's had one for years and he's sh*t. - Percy Drake , Shrewsbury Driven to the arms of Heineken by the wife

              M 1 Reply Last reply
              0
              • V vaghelabhavesh

                I assume you want to make the combox box read only, so that user can't type in. For that try changing the DropDownStyle property to "DropDownList"

                Books are as useful to a stupid person as a mirror is useful to a blind person. - Chanakya

                M Offline
                M Offline
                Mycroft Holmes
                wrote on last edited by
                #8

                I really, really hate missing the bloody obvious, all the faffing about with text boxes and events must have confused me, change the style, of course. mutter mutter bloody idiot

                V 1 Reply Last reply
                0
                • A Andy_L_J

                  Someone :^) didn't like your answer... I'll pay you back :thumbsup:

                  I don't speak Idiot - please talk slowly and clearly I don't know what all the fuss is about with America getting it's first black president. Zimbabwe's had one for years and he's sh*t. - Percy Drake , Shrewsbury Driven to the arms of Heineken by the wife

                  M Offline
                  M Offline
                  Mycroft Holmes
                  wrote on last edited by
                  #9

                  Considering Yogi's answer, :-O I didn't like it either but thanks anyway.

                  1 Reply Last reply
                  0
                  • M Mycroft Holmes

                    I really, really hate missing the bloody obvious, all the faffing about with text boxes and events must have confused me, change the style, of course. mutter mutter bloody idiot

                    V Offline
                    V Offline
                    vaghelabhavesh
                    wrote on last edited by
                    #10

                    Oh please calm down.. I guessed the issue because I know how some newbie ask the question. They want to do something else and ask something totally irrelevant.

                    Books are as useful to a stupid person as a mirror is useful to a blind person. - Chanakya

                    1 Reply Last reply
                    0
                    • V veeramani narayanasamy

                      I need Readonly ComboBox in vb.net windows application, for this requirement i used to use textbox & combobox together in the same place. TextBox Properties ReadOnly=True TabStop=False ComboBox Properties AutoCompleteMode=SuggestAppend AutoCompleteSource=ListItems TabStop=True in ADD/EDIT events set ComboBox Enabled=True, if the event is done ComboBox Enabled=False this is my code Private Sub ComboBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.GotFocus TextBox1.Visible = False End Sub Private Sub ComboBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.LostFocus TextBox1.Visible = True End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged TextBox1.Text = ComboBox1.SelectedItem().ToString End Sub in design TextBox on top of the ComboBox, can see only the ComboBox Button. Please give me any simple solution for this....

                      N.K.Veeramani Software Engineer InteriTech SDN. BHD., Malaysia

                      A Offline
                      A Offline
                      AhmedMasum
                      wrote on last edited by
                      #11

                      you can change the dropdownstyle property of combobox to dropdownlist. Then the user will not be able to change the content.

                      V 1 Reply Last reply
                      0
                      • A AhmedMasum

                        you can change the dropdownstyle property of combobox to dropdownlist. Then the user will not be able to change the content.

                        V Offline
                        V Offline
                        veeramani narayanasamy
                        wrote on last edited by
                        #12

                        that is ok but i want the same style in dropdown not in the dropdownlist thanks for your reply

                        N.K.Veeramani Software Engineer InteriTech SDN. BHD., Malaysia

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups