Using a TextBox inside a GroupBox
-
Sunday, January 13, 2013 2:24 AM
Hello,
please could you help me with coding.
I have two GroupBox (players, game)
Inside first box(players) I have two TextBoxs (name, surname)x(24rows) and in second (game) only one Label for each player.I need join name and surname from first GroupBox to Label in second GroupBox after press button inside first GroupBox.
I use GroupBox for easy hidden (property visible) all TextBoxes at once.
Sorry for my English.
Thanks Namrmic
All Replies
-
Sunday, January 13, 2013 3:05 AM
try this:
Label1.Text = Textbox1.Text & Textbox2.Text & Label1.Text
Label2.Text = Textbox3.Text & Textbox4.Text & Label2.Text
.
.
Label24.Text = Textbox47.Text & Textbox48.Text & Label24.Text
- Proposed As Answer by Carmelo La MonicaMicrosoft Community Contributor Sunday, January 13, 2013 11:13 AM
- Marked As Answer by Shanks ZenMicrosoft Contingent Staff, Moderator Thursday, January 17, 2013 7:43 AM
-
Sunday, January 13, 2013 11:09 AM
Namrmic
I assume it is windows forms. In that the Groupbox is not important for programming, you can just use the name of the textobxes
TheLabel = TextBoxFirstName.Text & " " & TextboxLastName.Text
Success
Cor- Proposed As Answer by Carmelo La MonicaMicrosoft Community Contributor Sunday, January 13, 2013 11:13 AM
- Marked As Answer by Shanks ZenMicrosoft Contingent Staff, Moderator Thursday, January 17, 2013 7:43 AM
-
Sunday, January 13, 2013 1:21 PM
Yes, I now about this but can I use For...Next, Do...Loop or any other function?
Thanks
-
Sunday, January 13, 2013 4:43 PM
You can do that in a For Index, however be aware it will cost your not much less code than writing those 24 lines and it is much more confusing.
It will be something like
Dim GroupBox1TextBoxes() As Control = {TextBox1, TexBox2, Textbox3} Dim Groupbox2TextBoxes() As Control = {TextBoxA, TexBoxB, TextboxC} Dim Groupbox2Labels() As Control = {Labely, Labelx, Labelz} For i = 0 To GroupBox1TextBoxes.Length - 1 Groupbox2Labels(i).Text = GroupBox1TextBoxes(i).Text & " " & Groupbox2TextBoxes(i).Text Next
Success
Cor- Edited by Cor LigthertMVP Sunday, January 13, 2013 4:44 PM
- Proposed As Answer by INDRA PRASETYA Sunday, January 13, 2013 5:10 PM
- Marked As Answer by Shanks ZenMicrosoft Contingent Staff, Moderator Thursday, January 17, 2013 7:43 AM
-
Sunday, January 13, 2013 5:41 PM
Hello namrmic,
another example with the use of liqtoobjects and of the collection, the whole then saved in a third collection that groups the data of the first two and displays them on the screen.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim myValueTextBox As List(Of String) = (From textbox In GroupBox1.Controls.OfType(Of TextBox)() Select textbox.Text).ToList() Dim myValueLabel As List(Of String) = (From label In GroupBox2.Controls.OfType(Of Label)() Select label.Text).ToList() Dim value As New List(Of String) For i As Integer = 0 To myValueTextBox.Count - 1 value.Add(String.Concat(myValueTextBox(i), myValueLabel(i))) Next For index As Integer = 0 To value.Count - 1 MessageBox.Show(value(index).ToString()) Next End SubRegards.
- Carmelo La Monica
- Visual Basic Tips e Tricks Blog
- WordPress.com Blog
- Blogger
- CrystalwebDotNetGroup
- Marked As Answer by namrmic Monday, January 14, 2013 12:29 AM

