Message 1 of 2
Format - iLogic Custom Made User Form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Good morning,
I'm working on building my first custom windows user form. I found majority of the following code on the forms here at,
I've been picking away at it for a little while now and feel confident with the code below. But am now looking to start adding text, images, and change various formatting options (such as background color). And I'm not entirely sure where to start. Does anyone have a good resource or class or example code I could look at to begin building the rest of this form?
Thank you for your time!
AddReference "System.Drawing" Imports System.ComponentModel Imports System.Drawing Imports System.Windows.Forms
Public Class WinForm Inherits System.Windows.Forms.Form ' Declare any thing here that you want to use/access throughout all Subs & Functions Public iLogicVb As Autodesk.iLogic.Interfaces.ILowLevelSupport Public oLargerFont As System.Drawing.Font = New Font("Arial", 10) Public Sub New() ' Creates the new instance oForm = Me With oForm .FormBorderStyle = FormBorderStyle.FixedToolWindow .StartPosition = FormStartPosition.CenterScreen .Width = 500 .Height = 750 .TopMost = True .Font = oLargerFont .Text = "Template" .Name = "Template" .ShowInTaskbar = False End With Dim oButton1 As New Button() With oButton1 .Text = "Buttom 1 Test" .Top = 25 .Left = 75 .Enabled = True .AutoSize = True End With oForm.Controls.Add(oButton1) AddHandler oButton1.Click, AddressOf oButton1_Click Dim oButton2 As New Button() With oButton2 .Text = "Buttom 2 Test" .Top = 125 .Left = 75 .Enabled = True .AutoSize = True End With oForm.Controls.Add(oButton2) AddHandler oButton2.Click, AddressOf oButton2_Click Dim oTextBox1 As New TextBox() With oTextBox1 .Text = "I am a Text Box" .Top = 225 .Left = 75 .Font = oLargerFont .Enabled = True .Width = 250 .Height = 50 End With oForm.Controls.Add(oTextBox1) AddHandler oTextBox1.Leave, AddressOf oTextBox1_Leave Dim oCheckBox1 As New CheckBox() With oCheckBox1 .Text = "Check Box" .Top = 325 .Left = 75 .Enabled = True .AutoSize = True End With oForm.Controls.Add(oCheckBox1) AddHandler oCheckBox1.CheckedChanged, AddressOf oCheckBox1_CheckedChanged Dim oComboBox1 As New ComboBox() With oComboBox1 .DataSource = {"A", "B", "C", "NA"} .Top = 425 .Left = 75 .Enabled = True .AutoSize = True End With oForm.Controls.Add(oComboBox1) AddHandler oComboBox1.SelectedIndexChanged, AddressOf oComboBox1_SelectedIndexChanged Dim oRadioButton1 As New RadioButton() With oRadioButton1 .Text = "Radio Button 1" .Top = 525 .Left = 75 .Enabled = True .AutoSize = True End With oForm.Controls.Add(oRadioButton1) AddHandler oRadioButton1.CheckedChanged, AddressOf oRadioButton1_CheckedChanged Dim oRadioButton2 As New RadioButton() With oRadioButton2 .Text = "Radio Button 2" .Top = 575 .Left = 75 .Enabled = True .AutoSize = True End With oForm.Controls.Add(oRadioButton2) AddHandler oRadioButton2.CheckedChanged, AddressOf oRadioButton2_CheckedChanged ' This is the end of the main Sub that defines the Form .SelectionChangeCommitted End Sub Private Sub WinForm_FormClosing(ByVal oSender As Object, ByVal oFormCloseEvents As FormClosingEventArgs) Handles Me.FormClosing ' 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) ' oSender is a Button MsgBox("You just clicked the [" & oSender.Text & "] button.", vbOKOnly + vbInformation, "EVENT FEEDBACK") ' iLogicVb.RunExternalRule("HML - BetaV017") End Sub Private Sub oButton2_Click(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) ' oSender is a Button MsgBox("You just clicked the [" & oSender.Text & "] button.",vbOKOnly+vbInformation,"EVENT FEEDBACK") 'iLogicVb.RunExternalRule("HML Update Tool") End Sub Private Sub oTextBox1_Leave(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) If oSender.Text <> oOriginalText Then 'oSender is a TextBox MsgBox("The contents of the TextBox have changed.", vbOKOnly + vbInformation, "EVENT FEEDBACK") End If End Sub Private Sub oCheckBox1_CheckedChanged(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) If oSender.Checked = True Then 'Sender is a CheckBox MsgBox("You just Checked the [" & oSender.Text & "] checkbox.", vbOKOnly + vbInformation, "EVENT FEEDBACK") Else MsgBox("You just UnChecked the [" & oSender.Text & "] checkbox.", vbOKOnly + vbInformation, "EVENT FEEDBACK") End If End Sub Private Sub oComboBox1_SelectedIndexChanged(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) ' oSender is a ComboBox MsgBox("You just chose " & oSender.Text & " from the ComboBox.",vbOKOnly+vbInformation,"EVENT FEEDBACK") End Sub Private Sub oRadioButton1_CheckedChanged(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) If oSender.Checked Then 'oSender is a RadioButton MsgBox("You just changed the Radio Button option to '" & oSender.Text & "'.", vbOKOnly + vbInformation, "EVENT FEEDBACK") Else ' MsgBox("You just changed the Radio Button option to 'Choice 2'.", vbOKOnly + vbInformation, "EVENT FEEDBACK") End If End Sub Private Sub oRadioButton2_CheckedChanged(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) If oSender.Checked Then 'oSender is a RadioButton MsgBox("You just changed the Radio Button option to '" & oSender.Text & "'.", vbOKOnly + vbInformation, "EVENT FEEDBACK") Else ' MsgBox("You just changed the Radio Button option to 'Choice 2'.", vbOKOnly + vbInformation, "EVENT FEEDBACK") End If End Sub End Class 'This is the code that actually shows/runs the Form Public Class RunMyForm Private Sub Main Dim oMyForm As New WinForm oMyForm.Show End Sub End Class