I guess this is a follow up to your other question. I don't understand your exact problem. but I figured I could show off some solutions for passing parameters around.
Notice
- I defined the variable _occName in the class (not in a function) therefore it's available in all functions. it is set and in the sub New and was used in the function MyClickFunction
- I defined the public property MyProperty. this is set in the MyClickFunction but used out site the winform class in the rule.
Hopefully you answer is solved like this.
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.ShowDialog()
MsgBox(oForm.MyProperty)
End Sub
Public Class WinForm
Inherits System.Windows.Forms.Form
Public oLargerFont As System.Drawing.Font = New Font("Arial", 10)
Private _occName As String
Public Property MyProperty As String
'//////// CREATE NEW INSTANCE ////////
Public Sub New(occName As String)
oForm = Me
_occName = occName
'//////// 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)
MyClickFunction("My param")
End Sub
Private Sub MyClickFunction(oParam As String)
MsgBox(_occName + " : " + oParam)
MyProperty = "I set my property here but it is used in the rule class"
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