Readonly ComboBox - Please give help?
-
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
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.
-
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.
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
-
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.
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
-
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
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.
-
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
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
-
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.
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
-
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
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
-
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
Considering Yogi's answer, :-O I didn't like it either but thanks anyway.
-
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
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
-
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
you can change the dropdownstyle property of combobox to dropdownlist. Then the user will not be able to change the content.
-
you can change the dropdownstyle property of combobox to dropdownlist. Then the user will not be able to change the content.
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