|
-
Oct 21st, 2011, 01:00 AM
#1
Thread Starter
New Member
[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:
Public Class QuestionDisplay
Inherits Windows.Forms.GroupBox
'Form Controls
Dim m_Question As New Windows.Forms.TextBox
Dim m_Comment As New Windows.Forms.TextBox
Dim m_GroupBox As New Windows.Forms.GroupBox
Dim m_rbtn1 As New Windows.Forms.RadioButton
Dim m_rbtn2 As New Windows.Forms.RadioButton
Dim m_rbtn3 As New Windows.Forms.RadioButton
Dim m_rbtn4 As New Windows.Forms.RadioButton
Dim m_rbtn5 As New Windows.Forms.RadioButton
'Positions
Dim m_xPos As Integer
Dim m_yPos As Integer
Public Sub New(ByVal xpos As Integer, ByVal ypos As Integer)
m_xPos = xpos
m_yPos = ypos
Me.Width = 470
Me.Height = 37
Me.Location = New Point(5, 26)
SetPositions()
End Sub
Private Sub SetPositions()
'ADD Question to GBO
m_Question.Location = New Point(1, 10)
m_Question.Width = 180
m_Question.Height = 20
m_Question.Name = "m_Question"
Me.Controls.Add(m_Question)
m_GroupBox.Location = New Point(190, 4)
m_GroupBox.Width = 100
m_GroupBox.Height = 30
m_GroupBox.Name = "m_GroupBox"
PositionRbtns()
AddRbtnsToGroupBox()
Me.Controls.Add(m_GroupBox)
'Add Comment to GBO
m_Comment.Location = New Point(300, 10)
m_Comment.Width = 170
m_Comment.Height = 20
m_Comment.Name = "m_Comment"
Me.Controls.Add(m_Comment)
End Sub
Private Sub PositionRbtns()
m_rbtn1.Location = New Point(5, 10)
m_rbtn1.Name = "m_rbtn1"
m_rbtn2.Location = New Point(25, 10)
m_rbtn2.Name = "m_rbtn2"
m_rbtn3.Location = New Point(45, 10)
m_rbtn3.Name = "m_rbtn3"
m_rbtn4.Location = New Point(65, 10)
m_rbtn4.Name = "m_rbtn4"
m_rbtn5.Location = New Point(85, 10)
m_rbtn5.Name = "m_rbtn5"
End Sub
Private Sub AddRbtnsToGroupBox()
m_GroupBox.Controls.Add(m_rbtn1)
m_GroupBox.Controls.Add(m_rbtn2)
m_GroupBox.Controls.Add(m_rbtn3)
m_GroupBox.Controls.Add(m_rbtn4)
m_GroupBox.Controls.Add(m_rbtn5)
End Sub
End Class
Last edited by shadowsofsorrow; Oct 21st, 2011 at 02:28 AM.
-
Oct 21st, 2011, 02:26 AM
#2
Re: dynamic radiobutton issue
Could you please wrap your code in [highlight="vb.net"][/highlight] tags to make it easier for people to read. Thank you! Also, your question is regarding vb.net so I have requested the thread moved.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 21st, 2011, 02:29 AM
#3
Thread Starter
New Member
Re: dynamic radiobutton issue
Sorry, did not realise there was such a thing
-
Oct 21st, 2011, 05:36 AM
#4
Re: dynamic radiobutton issue
Thread moved from the 'VB6 and Earlier' forum to the 'VB.Net' (VB2002 and later) forum (thanks Nightwalker83 )
-
Oct 21st, 2011, 09:01 AM
#5
Re: dynamic radiobutton issue
The code looks reasonable, but the positioning of the radiobuttons doesn't seem quite right. You are holding Y fixed and changing X. Technically, that should work, but in most cases, you see the X held constant and Y being changed such that the radio buttons stack vertically rather than forming a horizontal line.
EDIT: After looking at how you size the group box, I guess you meant to have it the way you do. However, you are adding all the radio buttons to the groupbox, which isn't as big as the whole control. I wonder whether or not you are not getting overlapping issues. You might comment out the control that is being displayed, and see whether that causes the next control to be displayed.
Last edited by Shaggy Hiker; Oct 21st, 2011 at 09:04 AM.
My usual boring signature: Nothing
 
-
Oct 24th, 2011, 11:36 PM
#6
Thread Starter
New Member
Re: dynamic radiobutton issue
Yeah that thing was it I didn't realise it would create the radiobutton with a bigger size than what it looked like it had, setting a default size fixed the problem, thanks a lot
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|