Message 1 of 2
Can't set location for windows form control with .location. Please Help
Not applicable
03-21-2013
09:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to create a windows form within iLogic. Everything works except the lines defining the location on the controls. I keep getting the following error: 'New' cannot be used on an interface. The error refers to lines in the code that try to set the control location on the form. (i.e. "button1.Location = New Point(10,10)") Ihave pasted the code below and have it attached as well. I am in Inventor 2013.
AddReference ("C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll")
Dim oOccurrence As ComponentOccurrence
Try
oOccurrence = ThisDoc.Document.SelectSet.Item(1)
Catch
MessageBox.Show("Please select a component before running this rule.", "iLogic")
Return
End Try
Dim doc As Document
Dim PName As String
Dim PNum As String
'set the selected item
oOccurrence = ThisApplication.ActiveDocument.SelectSet.Item(1)
PName = oOccurrence.Name
PNum = iProperties.Value(PName, "Custom", "Example_Property")
InputBox("Prompt", "Title",iProperties.Value(PName, "Custom", "Example_Property"))
' Create a new instance of the form.
Dim form1 As New Form()
' Create two buttons to use as the accept and cancel buttons.
Dim button1 As New System.windows.forms.Button()
Dim button2 As New System.windows.forms.Button()
Dim TextBox1 As New System.windows.forms.textbox()
' Set the text of button1 to "OK".
button1.Text = "OK"
' Set the position of the button on the form.
button1.Location = New Point(10,10)
' Set the text of button2 to "Cancel".
button2.Text = "Cancel"
' Set the position of the button based on the location of button1
button2.Location = New Point(button1.Left, button1.Height + button1.Top + 10)
' Set the text of TextBox1 to "Default".
TextBox1.Text = PNum
' Set the position of the button based on the location of button2
TextBox1.Location = New Point(button1.Left, button2.Height + button1.Top + 10)
' Set the caption bar text of the form.
form1.Text = "My Dialog Box"
' Display a help button on the form.
form1.HelpButton = True
' Define the border style of the form to a dialog box.
form1.FormBorderStyle = FormBorderStyle.FixedDialog
' Set the MaximizeBox to false to remove the maximize box.
form1.MaximizeBox = False
' Set the MinimizeBox to false to remove the minimize box.
form1.MinimizeBox = False
' Set the accept button of the form to button1.
form1.AcceptButton = button1
' Set the cancel button of the form to button2.
form1.CancelButton = button2
' Set the start position of the form to the center of the screen.
form1.StartPosition = FormStartPosition.CenterScreen
' Add button1 to the form.
form1.Controls.Add(button1)
' Add button2 to the form.
form1.Controls.Add(button2)
' Add textBox1 to the form.
form1.Controls.Add(TextBox1)
' Display the form as a modal dialog box.
form1.ShowDialog()
MessageBox.Show(TextBox1.text, Textbox1.text)
Thanks for lookng,
Thomas Ruscher