Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1176
bind a value list to a table field as old vb net grid
posted

hi i have a wingrid that is populated at ran time, can i set a colum to use a combolist and the valuelist be populated with another query using the binding property ?

i know i can do this

     Imports Infragistics.Shared
     Imports Infragistics.Win
     Imports Infragistics.Win.UltraWinGrid

    Private Sub Button9_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button9.Click
        If Me.ultraGrid1.DisplayLayout.ValueLists.Exists("VL1") Then Return

        Dim valueList As valueList = Me.ultraGrid1.DisplayLayout.ValueLists.Add("VL1")

        valueList.ValueListItems.Add(1, "One")
        valueList.ValueListItems.Add(2, "Two")

        Dim column As UltraGridColumn = Me.ultraGrid1.DisplayLayout.Bands(0).Columns(0)

        column.ValueList = valueList

        column.Style = ColumnStyle.DropDownValidate


    End Sub

also modify this to

 Public Sub AddValueList(ByVal WorkingGrid As UltraWinGrid.UltraGrid, ByVal ColumnName As String, ByVal ColStyle As ColumnStyle, ByVal ListName As String, ByVal SqlCommand As String, Optional ByVal BandNumber As Integer = 0)
        Dim DT As New DataTable
        Dim x As Integer

        If WorkingGrid.DisplayLayout.ValueLists.Exists(ListName) Then Return

        Dim valueList As ValueList = WorkingGrid.DisplayLayout.ValueLists.Add(ListName)

        valueList.ValueListItems.Clear()

        DT = CostPlanning.Conn.GetData(SqlCommand)

        If DT.Rows.Count > 0 Then

            For x = 0 To DT.Rows.Count - 1
                valueList.ValueListItems.Add(DT.Rows(x).Item(0))
                'valueList.ValueListItems.Add(1, "One")
            Next

        End If

        Dim column As UltraGridColumn = WorkingGrid.DisplayLayout.Bands(BandNumber).Columns(ColumnName)

        column.ValueList = valueList
        column.Style = ColStyle

    End Sub

but would like to do something like this

WorkingGrid.DisplayLayout.Bands(BandNumber).Columns(ColumnName).datasource = conn.getdata(sqlcommand)

is this posible? if yes can you provide me an  example please

Thanks.