Re: Reload or Refresh Form
InitializeComponents() is the method resposible of putting all items in your form
Re: Reload or Refresh Form
Hi,
In your case code should look for example like this:
VB Code:
Dim text As String = ""
Select Case Me.ComboBox1.Text
Case "yellow"
text = "yellow"
Case "blue"
text = "blue"
End Select
Me.TextBox1.Text = text
but if you want to populate textbox with value from combobox you don't need Select Case. You can do it simply like that:
VB Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim text As String
text = Me.ComboBox1.Text
Me.TextBox1.Text = text
End Sub
or simply by placing code into Combobox SelectedIndexChanged event handler:
VB Code:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Me.TextBox1.Text = Me.ComboBox1.Text
End Sub
Hope this helps.
Regards,
sweet_dreams
Re: Reload or Refresh Form
You are already populating the text box!
VB Code:
TextBox1.Text = (SelectedItem)
Re: Reload or Refresh Form
HI, Sweet_dreams
But if I do it that way, how can I tell which SelectItem the user has selected, my code is more involved then this, but I did not what to fill up post with code.
Dim text As String = ""
because if I have predined items, I can see your point, but I also would like to capture other user inputed items too.
So with that how can I get it to get predfined items and user added items to populate the textbox1
Thanks for your help, great explaination
Mike :wave:
Re: Reload or Refresh Form
Hi, Sweet_dreams
This does show blue in textbox1.text, but if a user inputs something else, how can I capture that.
Dim SelectedItem As String = ComboBox1.Text '("Whats your f color")
Dim Text As String = ""
Select Case LCase(ComboBox1.Text)
Case "blue"
Text = "Blue"
MsgBox("we have blue")
Me.TextBox1.Text = Text
Case "yellow"
MsgBox("we have yellow")
TextBox1.Text = (SelectedItem)
End Select
Thanks,
Mike
Re: Reload or Refresh Form
Sorry forgot to explain
TextBox1.Text = (SelectedItem)
why will this not work?
Also why do you refer to Me.TextBox1
I was trying Me.Refresh
any Ideas
Mike
Re: Reload or Refresh Form
Try this
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Select Case CStr(Me.ComboBox1.SelectedItem)
Case "blue"
Me.TextBox1.Text = "blue"
MsgBox("we have blue")
Case "yellow"
Me.TextBox1.Text = "yellow"
MsgBox("we have yellow")
End Select
End Sub
Re: Reload or Refresh Form
Quote:
Also why do you refer to Me.TextBox1
your form is a class object, to refer any property in a class you use "Me.PropertyName"
Re: Reload or Refresh Form
What is the purpose to refresh the form?
You don’t need to refresh the form!
Re: Reload or Refresh Form
HI, VBDT
This works good, but still will not let you, get selected user input,
say a user types red, but red it not in my items list, it will not populate the textbox1.text field??
Thanks all everyone help in this matter.
Mike
Re: Reload or Refresh Form
Then this is what you want
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myColor As String = CStr(Me.ComboBox1.SelectedItem)
Select Case myColor
Case "blue"
MsgBox("we have blue")
Case "yellow"
MsgBox("we have yellow")
End Select
Me.TextBox1.Text = myColor
End Sub
Re: Reload or Refresh Form
I found the fix:
I had to move the textbox1.text out of the select case statement, to below the end select?
in my program code I have many other line of code that write and read the registry, so why does this textbox1.text command not work inside the select case statements?
Thanks,
Mike
Select Case CStr(Me.ComboBox1.SelectedItem)
Case "blue"
TextBox1.Text = ComboBox1.Text ' I fix it by moving this statement out of the Select Case to below the End Select?
MsgBox("we have blue")
Case "yellow"
Me.TextBox1.Text = "yellow"
MsgBox("we have yellow")
End Select
TextBox1.Text = ComboBox1.Text
Re: Reload or Refresh Form
It does work in select case statement! Thus if you select ‘blue’ or ‘yellow’ colors the textbox will show the color names in it but if you select different colors from those the textbox will be empty because the textbox assigns value if the select case condition is true!