Message 1 of 1
Radiobuttons in Panel or Groupbox does not appear
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi can somebody help me with my code. I would like to use it to choose whether I would like to reset iproperties or not with yes or no radiobuttons (could not find a way of do it with checkboxes, maybe it is smoother). However The added radiobuttons in the panel does not appear in the Panel. It only appear in the correct position when I am adding the radiobuttons to the form but this is not working because it is not separated in to groups/panels.
Sub main() CreateForm("Knappar") MF.ShowDialog() End Sub Private GB(0) As System.Windows.Forms.Panel Private MF As System.Windows.Forms.Form Private BT(0) As System.Windows.Forms.Button Private CB(0) As System.Windows.Forms.ComboBox Private LB(0) As System.Windows.Forms.Label Private PB(0) As System.Windows.Forms.PictureBox Private RBY(0) As System.Windows.Forms.RadioButton Private RBN(0) As System.Windows.Forms.RadioButton Private TB(0) As System.Windows.Forms.TextBox Private GB0 As System.Windows.Forms.Panel Private TB_Desc As System.Windows.Forms.TextBox Private TB_Ritnr As System.Windows.Forms.TextBox Private TB_ANLMARKNING As System.Windows.Forms.TextBox Private GB1(0) As System.Windows.Forms.Panel Private Sub CreateForm(Optional Name As String = vbNullString) Dim drawDoc As Document drawDoc = ThisApplication.ActiveDocument MF = New System.Windows.Forms.Form MF.Text = Name MF.Size = New Drawing.Size(1700, 800) 'Width, Heigth MF.MinimumSize = MF.Size MF.MaximumSize = MF.Size MF.Font = New Drawing.Font(MF.Font.FontFamily, 10) MF.BackColor = System.Drawing.Color.White MF.MaximizeBox = False MF.MinimizeBox = False MF.ShowIcon = False MF.SizeGripStyle = SizeGripStyle.Hide MF.StartPosition = FormStartPosition.CenterScreen MF.AutoScaleMode = AutoScaleMode.Dpi 'MsgBox(System.Environment.GetFolderPath(System.Environment.SpecialFolder.UserProfile) & "\AFRY\iLogic - General\Bilder\Ritningshuvud_LKAB.png") '---------------------------------- 'Bakgrund rithuvud '---------------------------------- '---------------------------------- 'Ritnr '---------------------------------- Dim TBTEXT As String Dim row = 0 'GB0 for radiobuttons For i = 0 To ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties").Count ReDim Preserve GB1(i) GB1(i) = New System.Windows.Forms.Panel row = row + 50 GB1(i) = AddGB(5, row, "RB" & i) Next End Sub Private Function AddGB(PosX As Integer, PosY As Integer, Optional RadioName As String = vbNullString) As System.Windows.Forms.Panel Dim LC As Integer = GB.Length - 1 If Not GB(LC) Is Nothing Then LC = LC + 1 ReDim Preserve GB(LC) ReDim Preserve RBY(LC) ReDim Preserve RBN(LC) End If 'GB for Yes GB(LC) = New System.Windows.Forms.Panel 'GB(LC) = New System.Windows.Forms.GroupBox ' radioGroup.Location = New Drawing.Point(PosX, PosY) 'radioGroup.Size = New System.Drawing.Size(120, 30) ' radioGroup.Controls.Add(RBY(LC)) ' radioGroup.Controls.Add(RBN(LC)) ' MF.Controls.Add(radioGroup) 'MsgBox(RadioName) GB(LC).Left = PosX GB(LC).Top = PosY GB(LC).Size = New System.Drawing.Size(120, 30) GB(LC).BackColor = System.Drawing.Color.Gray 'Yes Radio RBY(LC) = New System.Windows.Forms.RadioButton RBY(LC).Name = RadioName & "Y" RBY(LC).Text = "Yes" RBY(LC).BackColor = System.Drawing.Color.White 'No Radio RBN(LC) = New System.Windows.Forms.RadioButton RBN(LC).Name = RadioName & "N" RBN(LC).Text = "No" RBN(LC).BackColor = System.Drawing.Color.White RBY(LC).Location = New Drawing.Point(PosX + 5, PosY + 5) RBY(LC).Width = 50 RBN(LC).Location = New Drawing.Point(PosX + 60, PosY + 5 ) RBN(LC).Width = 50 RBN(LC).Checked = True GB(LC).Name = RadioName ' Group the radio buttons GB(LC).Controls.Add(RBY(LC)) GB(LC).Controls.Add(RBN(LC)) MF.Controls.Add(GB(LC)) 'RBY(LC).BringToFront() ' ' MF.Controls.Add(RBN(LC)) ' MF.Controls.Add(RBY(LC)) ' RBY(LC).BringToFront() ' RBN(LC).BringToFront() Return GB(LC) End Function