Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
I have form created with Ilogic. The Form contains four radio buttons.
My goal is to change a custom property when user change radio button.
I've commented out the problem in line 76.
Does someone have any ideas how to do this?
Big shout out for the main code @WCrihfield
AddReference "System.Drawing"
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Public Class WinForm
Inherits System.Windows.Forms.Form
'Lista med olika tillverkningsmetoder
Private wordList As List(Of String) = New List(Of String) From {"Laserskuren", "Svarvad/Fräst", "3D-printad", "Inköpsdetalj"}
'Deklarerar Dictionary för att lagra Radio Buttons
Private radioButtons As Dictionary(Of String, RadioButton) = New Dictionary(Of String, RadioButton)
'Allmäna deklarationer för att använda i Subs & Functions
Public oLargerFont As System.Drawing.Font = New Font("Arial", 10)
Public Sub New() 'creates the new instance
'Formuläret
Dim oForm As System.Windows.Forms.Form = Me
With oForm
.FormBorderStyle = FormBorderStyle.FixedToolWindow
.StartPosition = FormStartPosition.CenterScreen
.Width = 300
.Height = 300
.TopMost = True
.Font = oLargerFont
.Text = "Windows Form"
.Name = "Windows Form"
.ShowInTaskbar = False
End With
'AddHandler oForm.FormClosing, AddressOf oForm_FormClosing
'Knapp
Dim oButton1 As New Button()
With oButton1
.Text = "TEST ME"
.Top = 25
.Left = 25
.Enabled = True
.AutoSize = True
End With
oForm.Controls.Add(oButton1)
AddHandler oButton1.Click, AddressOf oButton1_Click
'Skapa radio-knappar dynamiskt baserat på ordlistan
For Each word In wordList
Dim radioButton As New RadioButton()
radioButton.Text = word
radioButton.Top = oButton1.Bottom + 25 + wordList.IndexOf(word) * 30
radioButton.Left = 25
radioButton.AutoSize = True
radioButtons.Add(word, radioButton)
oForm.Controls.Add(radioButton)
AddHandler radioButton.CheckedChanged, AddressOf RadioButton_CheckedChanged
Next
End Sub
'This is the end of the main Sub that defines the Form
Private Sub oForm_FormClosing(ByVal oSender As Object, ByVal oFormCloseEvents As FormClosingEventArgs)
'oSender is a Form
If MsgBox("Are you sure you want to close this Form?",vbYesNo+vbQuestion, "CLOSE") = vbYes Then
Else
oFormCloseEvents.Cancel = True
End If
End Sub
Private Sub oButton1_Click(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs)
MsgBox("You just clicked the [" & oSender.Text & "] button.", vbOKOnly + vbInformation, "EVENT FEEDBACK")
End Sub
Public Sub RadioButton_CheckedChanged(sender As Object, e As EventArgs)
Dim selectedRadioButton As RadioButton = DirectCast(sender, RadioButton)
'iProperties.Value("Custom", "ManufacturingMethod") = selectedRadioButton.Text
End Sub
' Method to initialize the state of radio buttons based on ManufacturingMethod iProperty
Public Sub InitializeRadioButtons(ManufacturingMethod As String)
' Set the initial state of the radio buttons based on the ManufacturingMethod iProperty
'Dim manufacturingMethod As String = iProperties.Value("Custom", "ManufacturingMethod")
If wordList.Contains(ManufacturingMethod) Then
radioButtons(ManufacturingMethod).Checked = True
End If
End Sub
End Class
'This is the code that actually shows/runs the Form
Public Class RunMyForm
Private Sub Main()
' Create an instance of WinForm and pass iLogicVb
Dim oMyForm As New WinForm()
'this visibly launches the form
oMyForm.Show
Dim ManufacturingMethod As String = iProperties.Value("Custom", "ManufacturingMethod")
' Initialize the state of radio buttons based on ManufacturingMethod iProperty
oMyForm.InitializeRadioButtons(ManufacturingMethod)
End Sub
End Class
Solved! Go to Solution.