I am trying to make a dropdown cell/column in an UltraWinGrid. When I run the program and click on the PRCLEVEL cell it doesn't dropdown and it doesn't show anything. I also cannot type anything into the cell. Here is the entire form:
Option Explicit On
Option Strict On
Imports Centerprism.Data
Imports Infragistics.Win.UltraWinGrid
Imports Infragistics.Win
Imports OrderEntry.InfragisticsHelpers
Imports SharpUtilities, Prism.Core.Sql
Public Class frmPriceLevelAssignmentBySite
Private mdsPriceLevels As DataSet = Nothing
Dim mobjGlobals As Centerprism.Data.Interfaces.IRunPlainOldSql2
Private _vl As ValueList = New ValueList()
Public Sub New()
Me.InitializeComponent()
mobjGlobals = WebConnectionFactory.GlobalsWebProvider
End Sub
Private Sub frmPriceLevelAssignmentBySite_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
Cursor = Cursors.WaitCursor
Dim itemNumber As Integer
For Each prclevel As String In GetPriceLevels()
_vl.ValueListItems.Add(itemNumber,prclevel)
itemNumber += 1
Next
BindGrid()
Cursor = Cursors.Default
Catch ex As Exception
ErrorLogging.LogError(ex)
End Try
End Sub
Private Sub BindGrid()
mdsPriceLevels = New DataSet
Dim psSql As String
psSql = "SELECT [site].[LOCNCODE], [spl].PRCLEVEL FROM [dbo].[IV40700] [site] LEFT OUTER JOIN [cp].[SitePriceLevel] [spl] ON [site].[LOCNCODE] = [spl].[SiteId]"
mdsPriceLevels = mobjGlobals.GetData(psSql)
If mdsPriceLevels.IsSafe Then
grdPriceLevels.DataSource = mdsPriceLevels.Tables(0)
grdPriceLevels.Rows(0).Selected = True
End If
End Sub
Private Sub grdPriceLevels_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles grdPriceLevels.InitializeLayout
Try
With Me.grdPriceLevels.DisplayLayout
.ApplyDefaultPrismViewSettings()
.Override.AllowUpdate = DefaultableBoolean.True
.Bands(0).Columns("LOCNCODE").Header.VisiblePosition = 0
.Bands(0).Columns("LOCNCODE").Header.Caption = "Site Id"
.Bands(0).Columns("LOCNCODE").CellActivation = Activation.NoEdit
.Bands(0).Columns("PRCLEVEL").Header.VisiblePosition = 1
.Bands(0).Columns("PRCLEVEL").Header.Caption = "Price Level"
.Bands(0).Columns("PRCLEVEL").Style = ColumnStyle.DropDownValidate
.Bands(0).Columns("PRCLEVEL").ValueList = _vl
End With
Catch ex As Exception
ErrorLogging.LogError(ex)
End Try
End Sub
Private Function GetPriceLevels() As IEnumerable(Of String)
Dim sSql As String = "SELECT [PRCLEVEL] FROM [dbo].[IV40800]"
Dim ds As DataSet = mobjGlobals.GetData(sSql)
Dim list As IList(Of String) = New List(Of String)()
list.Add(String.Empty)
If ds.IsSafe() Then
For Each row As DataRow In ds.Tables(0).Rows
list.Add(row.Item("PRCLEVEL").ToString())
Next
End If
Return list
End Function
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Me.Close()
End Sub
Private Sub btnSelect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSelect.Click
Dim sSql As String
For Each row As UltraGridRow In grdPriceLevels.Rows
If row.Cells("PRCLEVEL").Value Is Nothing OrElse String.IsNullOrEmpty(row.Cells("PRCLEVEL").Value.ToString()) Then
sSql = $"DELETE FROM [cp].[SitePriceLevel] WHERE [SiteId] = '{row.Cells("LOCNCODE").Value.ToString()}'"
mobjGlobals.ExecuteDataByCommand(sSql, CommandType.Text, Nothing)
Continue For
End If
sSql = $"UPDATE [cp].[SitePriceLevel] SET [PRCLEVEL] = '{row.Cells("PRCLEVEL").Value.ToString()}' WHERE [LOCNCODE] = '{row.Cells("LOCNCODE").Value.ToString()}'"
If Not mobjGlobals.ExecuteDataByCommand(sSql, CommandType.Text, Nothing) Then
sSql = $"INSERT INTO [cp].[SitePriceLevel] ([LOCNCODE], [PRCLEVEL]) VALUES ('{row.Cells("LOCNCODE").Value.ToString()}', '{row.Cells("PRCLEVEL").Value.ToString()}'"
mobjGlobals.ExecuteDataByCommand(sSql, CommandType.Text, Nothing)
End If
Next
End Sub
End Class
I have checked and rechecked that the Value List is populated correctly. Any hints or help would be greatly appreciated.