My vb.net project includes a form with an Infragistics UltraGrid, in which one column, "Product_Code"` is a `DropDownList` style, populated by a ValueList.
What happens is, on the first row of the grid (Index 0), the item I select fills in the in the grid, and I can enter the rest of the data as I wish to.
However, when I add a second row (index 1 or higher), the ValueList remains the same, but whenever I click on a value, it inserts a `Null` or `Nothing` value into the "Product_Code" column. Is there anything alarmingly obvious which I'm doing wrong here?
I can't work out why this is happening
ugProducts.UpdateData()
For Each ugr In ugProducts.Rows If ugr.Cells("Product_Code").Value = ugProducts.Rows(ugProducts.Rows.Count - 1).Cells("Product_Code").Value And ugr.Index <> ugProducts.Rows(ugProducts.Rows.Count - 1).Index Then MsgBox("Cannot add the same product twice", MsgBoxStyle.OkOnly, "Error adding product") ugProducts.Rows(ugProducts.Rows.Count - 1).Delete(False) Exit Sub End If Next
Try If supplier = "" Then sql = "SELECT [Base_Code] FROM [Products]" dtProducts = getDT(sql)
For Each dr In dtProducts.Rows vlProducts.ValueListItems.Add(dr.Item("Base_Code"), dr.Item("Base_Code")) Next Else Dim ProductsDt As New DataTable
Using ProductsDa = New OleDbDataAdapter("SELECT [Product_Code] FROM [Product Suppliers] WHERE Supplier_Code=?", con) ProductsDa.SelectCommand.Parameters.Add("@suppliercode", OleDbType.VarChar).Value = supplier ProductsDa.Fill(ProductsDt) End Using
vlProducts.ValueListItems.Clear()
For Each dr In ProductsDt.Rows vlProducts.ValueListItems.Add(dr.Item("Product_Code"), dr.Item("Product_Code")) Next ugProducts.DisplayLayout.Rows(0).Cells("Product_Code").ValueList = vlProducts End If
Hi David,
In the code above, the value list is only added to the first row. Rather than adding the value list to the cell, you can add it to the column.
ugProducts.DisplayLayout.Bands[0].Columns[0].ValueList = vlProducts
Please try this out and let me know if it works.
Hi Mike,
No, this isn't the issue. The actual ValueList is being applied to the correct column and on all rows as it is. On each row, I can see all of the necessary items. The issue is that whenever I click on one of the items, it fills a null into the relevant cell. It works fine for selecting the first item, but whenever I want to choose a different one, all of the items appear, but clicking any of them enters in a null