So, I've got a grid with a drop-down list. It's in the 2nd column (the first column is actually hidden). Users create a series of rows in this grid and then it's exported to a spreadsheet. Works fine. However, we also IMPORT from the spreadsheet, and when we do, the code to create the dropdowns doesn't work - presumably because the data has been imported in and has set the schema. Instead of the dropdown in the first visible column ('Exhibit Type'), it ends up in the 2nd column.
I am happy to change the import methodology if that's the issue. Or do I have to somehow alter the schema after the import?
What I want to end up with is the proper values in all columns, of course, and the dropdown functional on EVERY row - even rows imported from the spreadsheet, so they can make changes if they want to.
Import code:
Private Sub Load_Grid_from_Disk() Dim myConnection As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & File_Path & ";Extended Properties=" myConnection = myConnection & Chr(34) & "Excel 12.0;HDR=YES" & Chr(34) ' ''myConnection = myConnection & Chr(34) & "Excel 12.0 Xml;HDR=YES" & Chr(34) Dim conn As OleDbConnection = New OleDbConnection(myConnection) Dim strSQL As String = "SELECT * FROM [Exhibits$]" Dim myCommand As OleDbCommand = New OleDbCommand(strSQL, conn) Dim DataSet As DataSet = New DataSet() Try Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(myCommand) Adapter.Fill(DataSet) Catch ex As Exception MsgBox(ex.ToString) End Try Ultragrid1.DataSource = DataSet End Sub
Code to create dropdown:
Private Sub Ultragrid1_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles Ultragrid1.InitializeLayout e.Layout.Bands(0).Columns(0).CellActivation = Activation.Disabled Dim vl As ValueList If (Not e.Layout.ValueLists.Exists("MyValueList")) Then vl = e.Layout.ValueLists.Add("MyValueList") vl.ValueListItems.Add(1, "B - Transfers Out") vl.ValueListItems.Add(2, "C - Transfers In") vl.ValueListItems.Add(3, "D - RTV") vl.ValueListItems.Add(4, "WRR - Purchase Orders") End If e.Layout.Bands(0).Columns(1).ValueList = e.Layout.ValueLists("MyValueList") e.Layout.Bands(0).Columns(1).Style = UltraWinGrid.ColumnStyle.DropDownList End Sub
I should have said it ends up in the NEXT column. So, the drop down gets offset to the right by one column when importing a spreadsheet compared to a new blank grid.
I'd love to add some jpegs, but can't see how. I don't have a 'URL' for the image. Most forums just let you browse disk and upload an image. What am I missing?