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
330
Default value to Ultracombo in Ultragrid
posted

Hello,

I have an ultracombo in the ultragrid. I would like to set the default value to "N/A" to the ultracombo from the dataset. Please help me out and below is the code and I don't know where im making a mistake.

Private Sub BindJurisdictionDropDown()
      JurisDT = GetJuris.Tables(0)-------{"AB","BC","CD","N/A"}
      ucb_Juri.SetDataBinding(JurisDT , Nothing)
      ucb_Juri.ValueMember = "JurisID"
      ucb_Juri.DisplayMember = "Juris"
End Sub

Private Sub UG_InitializeLayout(sender As Object, e As UltraWinGrid.InitializeLayoutEventArgs) Handles UG.InitializeLayout

Try

With e.Layout.Bands(0)
    .Columns("JID").TabStop = True

   .Columns("JID").ValueList = ucb_Juri

    .Columns("JID").MinWidth = 25
    .Columns("JID").Style = ColumnStyle.DropDownList

  For Each row As UltraGridRow In ucb_Juri.Rows()

     If row.Cells("JID").Text = "N/A" Then

              ucb_Juri.SelectedRow = row
     End If
  Next

End With

Catch

end Sub

Thanks,

AB

Parents
  • 23930
    Offline posted

    Hi AB,

    Thank you for posting in our forums.

    There are a few ways to do this. You can use the InitializeRow event of the UltraGrid and if the row is initialized for the first time, set the value of the cell to “N/A”:

    Private Sub UltraGrid1_InitializeRow(sender As Object, e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles UltraGrid1.InitializeRow

                If e.ReInitialize = False Then

                            e.Row.Cells(“JID”).Value = "N/A"

                End If

    End Sub

    An alternative approach, would be to set a default value for the column in the grid data table, before adding any rows:

    GridDataTable.Columns("JID").DefaultValue = "N/A"

    Please let me know if you have any additional questions.

Reply Children