This is a migrated thread and some comments may be shown as answers.

ComboBox with no DataSource

1 Answer 72 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jocelyn
Top achievements
Rank 1
Jocelyn asked on 13 Apr 2012, 08:25 PM
Hi,

I have a ComboBox  with no DataSource, in a GridEditForm, that I fill in the ItemRequested Event. I want to programatically select an item but, my combobox is empty until I click on it to fire the Event and then fill it. So is there a way to fill this combobox to select the right item? I am using this because I got alot of item in this combobox.

Here is my event sub:

Protected Sub cboGroupe_ItemsRequested(ByVal sender As Object, ByVal e As RadComboBoxItemsRequestedEventArgs)
    Dim cbo As RadComboBox = DirectCast(sender, RadComboBox)
 
    'get all customers whose name starts with e.Text
    Dim sqlGroupes As LWebStatement = ExecuteSql("Select gral_numero, gral_description " & _
                                            " from phfgrall where pram_sequence = " + GetStr(GSite_phfgrall) + " and (gral_numero like '" & Convert.ToString(e.Text) & _
                                            "%' or gral_description like '" & Convert.ToString(e.Text) & "%')" & _
                                            " order by gral_description")
    Dim itemOffset As Integer = e.NumberOfItems
    Dim endOffset As Integer = Math.Min(itemOffset + 10, sqlGroupes.Tables(0).Rows.Count)
    e.EndOfItems = endOffset = sqlGroupes.Tables(0).Rows.Count
 
    For i As Integer = itemOffset To endOffset - 1
        Dim item As RadComboBoxItem = New RadComboBoxItem(sqlGroupes.Tables(0).Rows(i)("gral_description").ToString, sqlGroupes.Tables(0).Rows(i)("gral_numero").ToString())
        item.Attributes("gral_description") = sqlGroupes.Tables(0).Rows(i)("gral_description").ToString
        item.Attributes("gral_numero") = sqlGroupes.Tables(0).Rows(i)("gral_numero").ToString
        cbo.Items.Add(item)
    Next
 
    e.Message = GetStatusMessage(endOffset, sqlGroupes.Tables(0).Rows.Count)
 
    cbo.DataBind()
End Sub

Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Cat Cheshire
Top achievements
Rank 1
answered on 16 Apr 2012, 11:27 AM
Tags
ComboBox
Asked by
Jocelyn
Top achievements
Rank 1
Answers by
Cat Cheshire
Top achievements
Rank 1
Share this question
or