Results 1 to 6 of 6

Thread: [RESOLVED] dynamic radiobutton issue

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2011
    Posts
    9

    Resolved [RESOLVED] dynamic radiobutton issue

    Trying to create a set of controls that can be used repeatedly without copy and paste code, including a textbox, a set of radiobuttons and then another textbox. Having a major problem in that I can only get one radiobutton to show up. The code I've created for it is below and as I've found this board helpful in the past I was hoping someone can help me out and explain what I've done wrong.
    vb.net Code:
    1. Public Class QuestionDisplay
    2.     Inherits Windows.Forms.GroupBox
    3.     'Form Controls
    4.     Dim m_Question As New Windows.Forms.TextBox
    5.     Dim m_Comment As New Windows.Forms.TextBox
    6.     Dim m_GroupBox As New Windows.Forms.GroupBox
    7.     Dim m_rbtn1 As New Windows.Forms.RadioButton
    8.     Dim m_rbtn2 As New Windows.Forms.RadioButton
    9.     Dim m_rbtn3 As New Windows.Forms.RadioButton
    10.     Dim m_rbtn4 As New Windows.Forms.RadioButton
    11.     Dim m_rbtn5 As New Windows.Forms.RadioButton
    12.     'Positions
    13.     Dim m_xPos As Integer
    14.     Dim m_yPos As Integer
    15.  
    16.     Public Sub New(ByVal xpos As Integer, ByVal ypos As Integer)
    17.         m_xPos = xpos
    18.         m_yPos = ypos
    19.         Me.Width = 470
    20.         Me.Height = 37
    21.         Me.Location = New Point(5, 26)
    22.         SetPositions()
    23.     End Sub
    24.  
    25.     Private Sub SetPositions()
    26.         'ADD Question to GBO
    27.         m_Question.Location = New Point(1, 10)
    28.         m_Question.Width = 180
    29.         m_Question.Height = 20
    30.         m_Question.Name = "m_Question"
    31.         Me.Controls.Add(m_Question)
    32.  
    33.         m_GroupBox.Location = New Point(190, 4)
    34.         m_GroupBox.Width = 100
    35.         m_GroupBox.Height = 30
    36.         m_GroupBox.Name = "m_GroupBox"
    37.         PositionRbtns()
    38.         AddRbtnsToGroupBox()
    39.         Me.Controls.Add(m_GroupBox)
    40.  
    41.         'Add Comment to GBO
    42.         m_Comment.Location = New Point(300, 10)
    43.         m_Comment.Width = 170
    44.         m_Comment.Height = 20
    45.         m_Comment.Name = "m_Comment"
    46.         Me.Controls.Add(m_Comment)
    47.     End Sub
    48.  
    49.     Private Sub PositionRbtns()
    50.         m_rbtn1.Location = New Point(5, 10)
    51.         m_rbtn1.Name = "m_rbtn1"
    52.         m_rbtn2.Location = New Point(25, 10)
    53.         m_rbtn2.Name = "m_rbtn2"
    54.         m_rbtn3.Location = New Point(45, 10)
    55.         m_rbtn3.Name = "m_rbtn3"
    56.         m_rbtn4.Location = New Point(65, 10)
    57.         m_rbtn4.Name = "m_rbtn4"
    58.         m_rbtn5.Location = New Point(85, 10)
    59.         m_rbtn5.Name = "m_rbtn5"
    60.     End Sub
    61.  
    62.     Private Sub AddRbtnsToGroupBox()
    63.         m_GroupBox.Controls.Add(m_rbtn1)
    64.         m_GroupBox.Controls.Add(m_rbtn2)
    65.         m_GroupBox.Controls.Add(m_rbtn3)
    66.         m_GroupBox.Controls.Add(m_rbtn4)
    67.         m_GroupBox.Controls.Add(m_rbtn5)
    68.     End Sub
    69. End Class
    Last edited by shadowsofsorrow; Oct 21st, 2011 at 02:28 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width