Hello everyone,
I'm trying to set the name of a selected part occurrence into a radiobutton of a form.
I'm using a shared variable to get the name from another rule. Everything works well, but in the end the name of the occurrence is missing in the form.
Does anyone know how to get the string I want into the form?
My code looks like this:
AddReference "System.Drawing" Imports System.ComponentModel Imports System.Drawing Imports System.Windows.Forms
Public Sub Main() '//////// GET THE OCCURRENCE NAME //////// Dim oOcc As String = SharedVariable("Occurrence") '//////// RUN THE FORM //////// Dim oForm As New WinForm oForm.Show End Sub
Public Class WinForm Inherits System.Windows.Forms.Form Public oLargerFont As System.Drawing.Font = New Font("Arial", 10) '//////// CREATE NEW INSTANCE //////// Public Sub New oForm = Me '//////// PARAMETERS FOR THE FORM //////// With oForm .FormBorderStyle = FormBorderStyle.FixedToolWindow .StartPosition = FormStartPosition.CenterScreen .Width = 300 .Height = 700 .TopMost = True .Font = oLargerFont .Text = "Component Select" .Name = "Components" .ShowInTaskbar = False End With Dim oButton1 As New Button() With oButton1 .Text = "MODIFY" .Top = 25 .Left = 25 .Enabled = True .AutoSize = True End With oForm.Controls.Add(oButton1) AddHandler oButton1.Click, AddressOf oButton1_Click Dim oOptions As New List(Of String) oOptions.AddRange({"Option 1","Option 2","Option 3"}) Dim oGroupBox As GroupBox = New GroupBox() oGroupBox.Left = 25 oGroupBox.Width = 150 oGroupBox.Top = oButton1.Bottom + 20 oGroupBox.Height = 100 oGroupBox.Text = "Choose" oForm.Controls.Add(oGroupBox) '//////// RADIOBUTTON PARAMETERS //////// Dim oRadioButton1 As New RadioButton() oGroupBox.Controls.Add(oRadioButton1) oRadioButton1.Text = oOcc.Name oRadioButton1.Top = 20 oRadioButton1.Left = 35 oRadioButton1.AutoSize = True End Sub Private Sub oButton1_Click(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) MsgBox("Action triggered",vbOKOnly+vbInformation,"EVENT FEEDBACK") End Sub End Class
Solved! Go to Solution.
Hello everyone,
I'm trying to set the name of a selected part occurrence into a radiobutton of a form.
I'm using a shared variable to get the name from another rule. Everything works well, but in the end the name of the occurrence is missing in the form.
Does anyone know how to get the string I want into the form?
My code looks like this:
AddReference "System.Drawing" Imports System.ComponentModel Imports System.Drawing Imports System.Windows.Forms
Public Sub Main() '//////// GET THE OCCURRENCE NAME //////// Dim oOcc As String = SharedVariable("Occurrence") '//////// RUN THE FORM //////// Dim oForm As New WinForm oForm.Show End Sub
Public Class WinForm Inherits System.Windows.Forms.Form Public oLargerFont As System.Drawing.Font = New Font("Arial", 10) '//////// CREATE NEW INSTANCE //////// Public Sub New oForm = Me '//////// PARAMETERS FOR THE FORM //////// With oForm .FormBorderStyle = FormBorderStyle.FixedToolWindow .StartPosition = FormStartPosition.CenterScreen .Width = 300 .Height = 700 .TopMost = True .Font = oLargerFont .Text = "Component Select" .Name = "Components" .ShowInTaskbar = False End With Dim oButton1 As New Button() With oButton1 .Text = "MODIFY" .Top = 25 .Left = 25 .Enabled = True .AutoSize = True End With oForm.Controls.Add(oButton1) AddHandler oButton1.Click, AddressOf oButton1_Click Dim oOptions As New List(Of String) oOptions.AddRange({"Option 1","Option 2","Option 3"}) Dim oGroupBox As GroupBox = New GroupBox() oGroupBox.Left = 25 oGroupBox.Width = 150 oGroupBox.Top = oButton1.Bottom + 20 oGroupBox.Height = 100 oGroupBox.Text = "Choose" oForm.Controls.Add(oGroupBox) '//////// RADIOBUTTON PARAMETERS //////// Dim oRadioButton1 As New RadioButton() oGroupBox.Controls.Add(oRadioButton1) oRadioButton1.Text = oOcc.Name oRadioButton1.Top = 20 oRadioButton1.Left = 35 oRadioButton1.AutoSize = True End Sub Private Sub oButton1_Click(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) MsgBox("Action triggered",vbOKOnly+vbInformation,"EVENT FEEDBACK") End Sub End Class
Solved! Go to Solution.
Solved by JelteDeJong. Go to Solution.
try it this way:
AddReference "System.Drawing" Imports System.ComponentModel Imports System.Drawing Imports System.Windows.Forms
Public Sub Main() '//////// GET THE OCCURRENCE NAME //////// Dim occ As ComponentOccurrence = ThisApplication.CommandManager.Pick( SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select occurrence") Dim occName As String = occ.Name '//////// RUN THE FORM //////// Dim oForm As New WinForm(occName) oForm.Show End Sub Public Class WinForm Inherits System.Windows.Forms.Form Public oLargerFont As System.Drawing.Font = New Font("Arial", 10) '//////// CREATE NEW INSTANCE //////// Public Sub New(occName As String) oForm = Me '//////// PARAMETERS FOR THE FORM //////// With oForm .FormBorderStyle = FormBorderStyle.FixedToolWindow .StartPosition = FormStartPosition.CenterScreen .Width = 300 .Height = 700 .TopMost = True .Font = oLargerFont .Text = "Component Select" .Name = "Components" .ShowInTaskbar = False End With Dim oButton1 As New Button() With oButton1 .Text = "MODIFY" .Top = 25 .Left = 25 .Enabled = True .AutoSize = True End With oForm.Controls.Add(oButton1) AddHandler oButton1.Click, AddressOf oButton1_Click Dim oOptions As New List(Of String) oOptions.AddRange({"Option 1","Option 2","Option 3"}) Dim oGroupBox As GroupBox = New GroupBox() oGroupBox.Left = 25 oGroupBox.Width = 150 oGroupBox.Top = oButton1.Bottom + 20 oGroupBox.Height = 100 oGroupBox.Text = "Choose" oForm.Controls.Add(oGroupBox) '//////// RADIOBUTTON PARAMETERS //////// Dim oRadioButton1 As New RadioButton() oGroupBox.Controls.Add(oRadioButton1) oRadioButton1.Text = occName oRadioButton1.Top = 20 oRadioButton1.Left = 35 oRadioButton1.AutoSize = True End Sub Private Sub oButton1_Click(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) MsgBox("Action triggered",vbOKOnly+vbInformation,"EVENT FEEDBACK") End Sub End Class
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com
try it this way:
AddReference "System.Drawing" Imports System.ComponentModel Imports System.Drawing Imports System.Windows.Forms
Public Sub Main() '//////// GET THE OCCURRENCE NAME //////// Dim occ As ComponentOccurrence = ThisApplication.CommandManager.Pick( SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select occurrence") Dim occName As String = occ.Name '//////// RUN THE FORM //////// Dim oForm As New WinForm(occName) oForm.Show End Sub Public Class WinForm Inherits System.Windows.Forms.Form Public oLargerFont As System.Drawing.Font = New Font("Arial", 10) '//////// CREATE NEW INSTANCE //////// Public Sub New(occName As String) oForm = Me '//////// PARAMETERS FOR THE FORM //////// With oForm .FormBorderStyle = FormBorderStyle.FixedToolWindow .StartPosition = FormStartPosition.CenterScreen .Width = 300 .Height = 700 .TopMost = True .Font = oLargerFont .Text = "Component Select" .Name = "Components" .ShowInTaskbar = False End With Dim oButton1 As New Button() With oButton1 .Text = "MODIFY" .Top = 25 .Left = 25 .Enabled = True .AutoSize = True End With oForm.Controls.Add(oButton1) AddHandler oButton1.Click, AddressOf oButton1_Click Dim oOptions As New List(Of String) oOptions.AddRange({"Option 1","Option 2","Option 3"}) Dim oGroupBox As GroupBox = New GroupBox() oGroupBox.Left = 25 oGroupBox.Width = 150 oGroupBox.Top = oButton1.Bottom + 20 oGroupBox.Height = 100 oGroupBox.Text = "Choose" oForm.Controls.Add(oGroupBox) '//////// RADIOBUTTON PARAMETERS //////// Dim oRadioButton1 As New RadioButton() oGroupBox.Controls.Add(oRadioButton1) oRadioButton1.Text = occName oRadioButton1.Top = 20 oRadioButton1.Left = 35 oRadioButton1.AutoSize = True End Sub Private Sub oButton1_Click(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) MsgBox("Action triggered",vbOKOnly+vbInformation,"EVENT FEEDBACK") End Sub End Class
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com
That is exactly what I needed to work with the variable inside the class.
Thank you.
That is exactly what I needed to work with the variable inside the class.
Thank you.
Can't find what you're looking for? Ask the community or share your knowledge.