Setting drawing properties with a ComboBox

Setting drawing properties with a ComboBox

Anonymous
Not applicable
461 Views
9 Replies
Message 1 of 10

Setting drawing properties with a ComboBox

Anonymous
Not applicable
I am using the following code to set a custom drawing property in ACAD 2005 using a ComboBox and DropDown list. The code works fine except for when you type in a value that is not in the list. Any help will be much appreciated. Style = 0-fmStyleDropDownCombo Locked = False Private Sub ComboBox2_Click() Dim Key1 As String Dim Value1 As String Dim CustomPropertyLine As String Dim PropertyLineValue As String ComboBox2.DropDown ' Set value for Line CustomPropertyLine = "Line" ThisDrawing.SummaryInfo.GetCustomByIndex 1, Key1, Value1 ThisDrawing.SummaryInfo.SetCustomByIndex 1, CustomPropertyLine, ComboBox2.Value End Sub Private Sub UserForm_Initialize() ComboBox2.AddItem "LINE1" ComboBox2.AddItem "LINE2" ComboBox2.AddItem "LINE3"
0 Likes
462 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable
Have you tried using the ComboBox2_Change Method? "Ray Feiler" wrote in message news:41ffe89f_1@newsprd01... > I am using the following code to set a custom drawing property in ACAD 2005 > using a ComboBox and DropDown list. The code works fine except for when you > type in a value that is not in the list. Any help will be much appreciated. > > Style = 0-fmStyleDropDownCombo > Locked = False > > Private Sub ComboBox2_Click() > > Dim Key1 As String > Dim Value1 As String > > Dim CustomPropertyLine As String > Dim PropertyLineValue As String > > ComboBox2.DropDown > > ' Set value for Line > CustomPropertyLine = "Line" > ThisDrawing.SummaryInfo.GetCustomByIndex 1, Key1, Value1 > ThisDrawing.SummaryInfo.SetCustomByIndex 1, CustomPropertyLine, > ComboBox2.Value > > End Sub > > Private Sub UserForm_Initialize() > > ComboBox2.AddItem "LINE1" > ComboBox2.AddItem "LINE2" > ComboBox2.AddItem "LINE3" > >
0 Likes
Message 3 of 10

Anonymous
Not applicable
No, and in the help file I can only find information on the Add Method. How would I use the Change Method to get the value for what is type in the ComboBox by the user and pass it to ComboBox2.Value?
0 Likes
Message 4 of 10

Anonymous
Not applicable
Hi Ray, If you use a list box the user cannot type data into it, only select from the values you load into it. -- Regards, Laurie Comerford www.cadapps.com.au "Ray Feiler" wrote in message news:41ffe89f_1@newsprd01... >I am using the following code to set a custom drawing property in ACAD 2005 > using a ComboBox and DropDown list. The code works fine except for when > you > type in a value that is not in the list. Any help will be much > appreciated. > > Style = 0-fmStyleDropDownCombo > Locked = False > > Private Sub ComboBox2_Click() > > Dim Key1 As String > Dim Value1 As String > > Dim CustomPropertyLine As String > Dim PropertyLineValue As String > > ComboBox2.DropDown > > ' Set value for Line > CustomPropertyLine = "Line" > ThisDrawing.SummaryInfo.GetCustomByIndex 1, Key1, Value1 > ThisDrawing.SummaryInfo.SetCustomByIndex 1, CustomPropertyLine, > ComboBox2.Value > > End Sub > > Private Sub UserForm_Initialize() > > ComboBox2.AddItem "LINE1" > ComboBox2.AddItem "LINE2" > ComboBox2.AddItem "LINE3" > >
0 Likes
Message 5 of 10

Anonymous
Not applicable
I want the user to be able to type in the value if it is not in the list. What is happening when I run my code you can type in the value but it does not get passed to ComboBox2.Value. I have set Style = 0-fmStyleDropDownCombo and Locked = False but it still does not work.
0 Likes
Message 6 of 10

Anonymous
Not applicable
Change Private Sub ComboBox2_Click()
to Private Sub ComboBox2_Change()
0 Likes
Message 7 of 10

Anonymous
Not applicable
Thank you very much Nathan. That did exactly what I needed. If it isn't too much trouble to ask I have one more problem with this code that I have not been able to solve. How can I get the current values for the custom properties to display in the ComboBox?
0 Likes
Message 8 of 10

Anonymous
Not applicable
Here is what I came up with on my own. I'm not sure if it is the best method though. Dim Key1 As String Dim Value1 As String Dim CustomPropertyLine As String Dim PropertyLineValue As String Dim LineIndex As String ' Get value for Line CustomPropertyLine = "Line" ThisDrawing.SummaryInfo.GetCustomByIndex 1, Key1, Value1 If Value1 = "Line1" Then LineIndex = "0" ElseIf Value1 = "Line2" Then LineIndex = "1" Else: LineIndex = "2" End If ComboBox2.AddItem "Line1" 'ListIndex = 0 ComboBox2.AddItem "Line2" 'ListIndex = 1 ComboBox2.AddItem "Line3" 'ListIndex = 2
0 Likes
Message 9 of 10

Anonymous
Not applicable
This works better. Less code because you do not need to index everything. Dim Key1 As String Dim Value1 As String Dim CustomPropertyLine As String Dim PropertyLineValue As String ' Get value for Line CustomPropertyLine = "Line" ThisDrawing.SummaryInfo.GetCustomByIndex 1, Key1, Value1 ComboBox2.AddItem Value1 ComboBox2.AddItem "Line1" ComboBox2.AddItem "Line2" ComboBox2.AddItem "Line3" ComboBox2.ListIndex = 0
0 Likes
Message 10 of 10

Anonymous
Not applicable
I cleaned it up some more. Dim Key1 As String Dim Value1 As String ' Get current value for custom property Line ThisDrawing.SummaryInfo.GetCustomByIndex 1, Key1, Value1 ComboBox2.AddItem Value1 ComboBox2.AddItem "Line1" ComboBox2.AddItem "Line2" ComboBox2.AddItem "Line3" ComboBox2.ListIndex = 0
0 Likes