Answered 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
     
     Answered

    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

  • Sunday, January 13, 2013 11:09 AM
     
     Answered Has Code

    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

  • 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
     
     Answered Has Code

    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


  • Sunday, January 13, 2013 5:41 PM
     
     Answered Has Code

    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 Sub

    Regards.


    • Marked As Answer by namrmic Monday, January 14, 2013 12:29 AM
    •