Message 1 of 1
Dependent Drop Down with iLogic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, everybody,
I created a form screen belonging to Workstations for Operations. But I want to do this in the "Dependent Drop Down" in the combo boxes I created. Can you help me?
Imports System.Windows.Forms
Imports System.Drawing
Imports System
Imports System.Math
Imports System.Collections
Imports Microsoft.VisualBasic
Imports Autodesk.iLogic.Interfaces
Imports Autodesk.iLogic.Runtime
AddReference "System.Drawing.dll"
Public Sub Main()
' FORM EKRANI OLUŞTURMA KODU
Dim form As New System.Windows.Forms.Form()
form.Text = "Kaydetme Formu"
form.Height = 800
form.Width = 1000
'PictureBox Ekleyen SATIR
Dim pictureBox As New PictureBox()
pictureBox.Location = New System.Drawing.Point(360, 590)
pictureBox.Size = New Size(300, 90)
pictureBox.SizeMode = PictureBoxSizeMode.StretchImage
pictureBox.Image = Image.FromFile("Z:\templates\SEYİT USTA LOGO.png") ' Resim dosya yolunu güncelleyin
form.Controls.Add(pictureBox)
Dim headLabel As New Label()
headLabel.Text = "Operation"
headLabel.Location = New System.Drawing.Point(260, 10)
headLabel.Size = New Size(300, 20)
headLabel.Font = New Font("Arial", 15)
form.Controls.Add(headLabel)
Dim headLabel1 As New Label()
headLabel1.Text = "Work Station"
headLabel1.Location = New System.Drawing.Point(660, 10)
headLabel1.Size = New Size(300, 20)
headLabel1.Font = New Font("Arial", 15)
form.Controls.Add(headLabel1)
' OPRERASYONLARIN YER ALDIĞI LİST
Dim labels() As String = {"OPR1", "OPR2", "OPR3", "OPR4", "OPR5", "OPR6", "OPR7", "OPR8" }
For i As Integer = 0 To labels.Length - 1
Dim labelText As New Label()
labelText.Text = labels(i)
labelText.Location = New System.Drawing.Point(100, 50 + (i * 40))
labelText.Font = New Font("Arial", 14)
form.Controls.Add(labelText)
Next
Dim OperationNames As String()() = {New String() { "LAZER KESİM", "PLAZMA KESİM", "TESTERE KESİM" },
New String() { "BÜKÜM", "TORNA", "OKSİJEN KESİM" },
New String() { "DELİK DELME", "AAA", "BBB" },
New String() { "DİŞ AÇMA", "D", "E" },
New String() { "F", "G", "H" },
New String() { "I", "J", "K " },
New String() { "L", "M", "N " },
New String() { "X", "Y", "Z " }}
Dim orpcb As New List(Of ComboBox)
For i As Integer = 0 To OperationNames.Length - 1
Dim comboBox As New ComboBox()
comboBox.Items.AddRange(OperationNames(i))
comboBox.Location = New System.Drawing.Point(200, 50 + i * 40)
comboBox.Size = New Size(275, comboBox.Size.Height)
comboBox.Font = New Font("Arial", 14)
form.Controls.Add(comboBox)
orpcb.Add(comboBox)
Next
' İŞ İSTASYONLARININ YER ALDIĞI LİST
Dim labels1() As String = {"İŞ İST1", "İŞ İST2", "İŞ İST3", "İŞ İST4", "İŞ İST5", "İŞ İST6", "İŞ İST7", "İŞ İST8" }
For i As Integer = 0 To labels1.Length - 1
Dim labelText As New Label()
labelText.Text = labels1(i)
labelText.Location = New System.Drawing.Point(500, 50 + (i * 40))
labelText.Font = New Font("Arial", 14)
form.Controls.Add(labelText)
Next
Dim isistname As String()() = {New String() { "CNC MACHİNE", "CNC PLAZMA KESİM", "KAR METAL" },
New String() { "ABKANT DURMAZLAR", "" },
New String() { "DELİK DELME", "B", "C" },
New String() { "DİŞ AÇMA", "D", "E" },
New String() { "F", "G", "H" },
New String() { "I", "J", "K " },
New String() { "L", "M", "N " },
New String() { "X", "Y", "Z " }}
Dim isistcb As New List(Of ComboBox)
For i As Integer = 0 To isistname.Length - 1
Dim comboBox As New ComboBox()
comboBox.Items.AddRange(isistname(i))
comboBox.Location = New System.Drawing.Point(600, 50 + i * 40)
comboBox.Size = New Size(275, comboBox.Size.Height)
comboBox.Font = New Font("Arial", 14)
form.Controls.Add(comboBox)
isistcb.Add(comboBox)
Next
' KAYDET BUTONU OLUŞTURMA KODU
Dim saveButton As New System.Windows.Forms.Button()
saveButton.Text = "SAVE"
saveButton.Location = New System.Drawing.Point(450, 400)
saveButton.Height = 80
saveButton.Width = 140
saveButton.Font = New System.Drawing.Font("Arial", 12, System.Drawing.FontStyle.Bold)
AddHandler saveButton.Click, AddressOf SaveButton_Click
form.Controls.Add(saveButton)
System.Windows.Forms.Application.Run(form)
End Sub
' KAYDET BUTONUNA BASILDIĞINDA GERÇEKLEŞECEK EYLEMLERİN YER ALDIĞI SUB KODLARI
Sub SaveButton_Click(sender As Object, E As EventArgs)
Dim Form As System.Windows.Forms.Form = CType(sender, System.Windows.Forms.Button).FindForm()
Dim comboBoxValues As New List(Of String)
' Her iki gruptaki ComboBox'ların etiketlerini tanımlayın
Dim operationLabels() As String = {"OPR1", "OPR2", "OPR3", "OPR4", "OPR5", "OPR6", "OPR7", "OPR8" }
Dim stationLabels() As String = {"İŞ İST1", "İŞ İST2", "İŞ İST3", "İŞ İST4", "İŞ İST5", "İŞ İST6", "İŞ İST7", "İŞ İST8" }
For Each ComboBox As System.Windows.Forms.ComboBox In Form.Controls.OfType(Of System.Windows.Forms.ComboBox)()
If ComboBox.SelectedItem IsNot Nothing Then
comboBoxValues.Add(ComboBox.SelectedItem.ToString())
End If
Next
Dim oInvApp As Inventor.Application = ThisApplication
Dim oDoc As Inventor.Document = oInvApp.ActiveDocument
Dim oCustom As PropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties")
For i As Integer = 0 To comboBoxValues.Count / 2 - 1
Dim comboBoxValue As String = comboBoxValues(i)
If Not String.IsNullOrEmpty(comboBoxValue) Then
Dim propertyName As String = String.Empty
propertyName = operationLabels(i)
If Not String.IsNullOrEmpty(propertyName) Then
Try
oCustom.Item(propertyName).Value = comboBoxValue
Catch
oCustom.Add(comboBoxValue, propertyName)
End Try
End If
End If
Next
For i As Integer = 0 To comboBoxValues.Count / 2 - 1
Dim comboBoxValue As String = comboBoxValues(i + comboBoxValues.Count / 2)
If Not String.IsNullOrEmpty(comboBoxValue) Then
Dim propertyName As String = String.Empty
propertyName = stationLabels(i)
If Not String.IsNullOrEmpty(propertyName) Then
Try
oCustom.Item(propertyName).Value = comboBoxValue
Catch
oCustom.Add(comboBoxValue, propertyName)
End Try
End If
End If
Next
End Sub