I am creating a new software with visual studio 2010 using the program language visual basic .NET, well in that software I create a new file in excel 2007, my question is because I do not know how I can create a combobox with data of my database inside, I will be appreciate your help a lot, thank for your time.
To create the combobox I use the next code in a button of my windows form, It actually is an adaptation of the code shared by sammyB (http://bytes.com/topic/net/answers/614371-using-vb-net-dynamically-create-excel-activex-controls):
Expand|Select|Wrap|Line Numbers
- Dim xlApp As Excel.Application
- Dim xlBook As Excel.Workbook
- Dim xlSheet As Excel.Worksheet
- Dim xlcombobox As Excel.OLEObject
- Dim iStartLine As Long
- xlApp = New Excel.Application
- xlApp.Visible = True
- xlBook = xlApp.Workbooks.Add
- xlSheet = xlBook.ActiveSheet
- xlcombobox = xlSheet.OLEObjects.Add(ClassType:="Forms.combobox.1", _
- Link:=False, DisplayAsIcon:=False, Left:=1, Top:=25, Width:=72, Height:=24)
- xlcombobox.Name = "clientes"