• Kieth
  • Newbie Topic Starter

I want to allow users to add a new item to a dropdown list. Is it possible to add to the items of a drop down list after it has been attached to the Grid?
I also want to be able to do this with multicolumn drop down lists.

Thanks in advance

Yes, you can always add new items to drop-down lists from code after they were attached to iGrid.
  • Kieth
  • Newbie Topic Starter
I’m sorry. Maybe I didn’t express my request properly.
How do you add to the items of a dropdown list already attached to the grid.
How do you add extra items in code (VB)? I cannot find any examples of this being done.
Or do you need to create a new dropdown list with the extra data and then attach that to the required column?
The topic '19.3.1. The Basics of Combo Box Cells' in the current version of the manual shows how you can create an instance of the built-in drop-down list class and populate it with items one-by-one:

Dim myDropDownList As New iGDropDownList()

You can find other methods of the iGDropDownList class and its item collection represented by the Items property (the iGDropDownList.iGDropDownListItemCollection class) in the electronic help system.

If you need any help, feel free to ask here too.
  • Kieth
  • Newbie Topic Starter
I understand how to create a dropdown list, add items to it and then connect it to a column in the Grid. What I need is this....
Here is a scenario....
A dropdown list containing a list of car models is attached to a column so the user can select the desired model. The car manufacturer brings out a new model. How can I as a programmer add the new model to the list?

One way I have thought of is to create a new dropdown list with the new model inserted and then attach the new dropdown list to the grid’s column. This however would require a new list every time a new item is to be added.

Is there an easier way, by referencing the current dropdown list in code, and how do you reference it?

Thanks - Kieth
I thought I answered your question. You add a new item using a statement like this:
myDropDownList.Items.Add("New car model")

I have another suggestion how we can help you. Can you create a simple project demonstrating how you use iGrid drop-down lists and send it to us? Then we could simply modify your code to show how to do what you need.

Note: To avoid blocking your letter, please, remove the bin, obj and the hidden .vs folders with executable contents from the solution before packing it into a zip-archive. They will be re-created the next time you compile your solution.
  • Kieth
  • Newbie Topic Starter
I think you missed the point of the question. It was not 'How do you add a new item to a dropdown list' but rather 'How do you ad a new item to a dropdown list that already exists in the grid?

I found the following code works in VB

dim strModel as string
strModel = "New Model"
Dim myDDL As New iGDropDownList()
 'This is the line I was looking for, how to reference an existing dropdown list
 myDDL = CType(ItemsGrid.Cols(5).CellStyle.DropDownControl, iGDropDownList)  ' This line points the new dropdown list to the required existing one, and modifies it
 ItemsGrid.Cells(iCurrRow, iCurrCol).Value = strModel
No, I didn't miss it :)
Actually your question should have been this: how to get a drop-down list attached to a given cell [to add new items to it]? And if you provided some code showing how you initialize your grid, this would help a lot. Ok, no matter - just one comment.

There is no need to create a new instance of the drop-down list object in line 3 and then rewrite it with the cell's drop-down list in line 5. it should be one statement:
Dim myDDL As iGDropDownList = CType(ItemsGrid.Cols(5).CellStyle.DropDownControl, iGDropDownList)
Or even simpler if you work with the built-in drop-down list objects:
Dim myDDL As iGDropDownList = ItemsGrid.Cols(5).CellStyle.DropDownControl