RadDropDownList FindItem method

6 posts, 1 answers
  1. Veshala
    Veshala avatar
    27 posts
    Member since:
    Aug 2009

    Posted 10 Feb 2011 Link to this post


    FindItem(string StartsWith) method of RadComboBox to return a RadComboBoxItem with text starting with a given string.

    RadComboBoxItem item = radComboBox1.FindItem(strString);

    What is the equivalent method in RadDropDownList to find item starting with a given string.

    Any help is appreciated.

  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 10 Feb 2011 Link to this post


    This is one way to get back an item

    int itemIndex = this.radDropDownList1.FindString("TheStringToFind");
    if (itemIndex > -1)
    else{MessageBox.Show("not found");}

    Hope that helps
  3. DevCraft banner
  4. Peter
    Peter avatar
    1148 posts

    Posted 11 Feb 2011 Link to this post

    Hello Vanita,

    Thank you for the writing.

    In RadListControl and RadDropDownList's FindString method searches for an item related to the specified string and returns the index of the found item or -1 if no item is found.

    So you should use Ricard's solution to find the item.

    Do not hesitate to contact us if you have other questions.

    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  5. RJ
    RJ avatar
    384 posts
    Member since:
    Oct 2006

    Posted 06 Dec 2012 Link to this post

    How about for combo.Items.FindByValue whats the equivalent for RadDropdownList?

    coz Im having a problem with raddropdownlist.selectedvalue = to my data  which is not firing up.  but for selectedindex its firing up. So I need the code to get the index which is find by value or the valuemember, not the displaymember

    Its just weird for just a simple setting of selected value, only the first 4 radDropdownlist  works and the rest stays at selected index -1
    I did change several RadDropdownlist to Wincontrols.Combobox and it works without any problem.
    Im using Wincontrols Q2 2012

     Private Sub PopulateBarcodeData()
            Dim DTBarcode As New DataTable
            Dim Row As DataRow
            DTBarcode = GetDataTable("Select * from tblBarcodeData where barcodedataid = " & DataID)
            If Not DTBarcode.Rows.Count = 0 Then

                Row = DTBarcode.Rows(0)

    'only 4 items works

                Me.cboItems.SelectedValue = CInt(IsDbaseNull(Row("ItemID"), 0))  
                Me.cboBatchNo.SelectedValue = IsDbaseNull(Row("Item Batch No"), "0")        
                Me.cboMixPlain.SelectedValue = CInt(IsDbaseNull(Row("Mix Plain"), 0))
                Me.cboMixChoco.SelectedValue = CInt(IsDbaseNull(Row("Mix Choco"), 0))

    'the rest has problems

                Me.cboMachineNo.SelectedValue = CInt(IsDbaseNull(Row("Machine No"), 0))
                Me.cboFlour.SelectedIndex = cint(IsDbaseNull(Row("FlourID")), 0)

                Me.cboSoyaLecithin.SelectedValue = CInt(IsDbaseNull(Row("SoyaID"), 0))
                Me.cboSugar.SelectedValue = Cint(IsDbaseNull(Row("SugarID"),0))
                Me.cboStickerSupplier.SelectedValue = CInt(IsDbaseNull(Row("Sticker SupplierID"), 0))
                Me.cboSleevesSupplier.SelectedValue = CInt(IsDbaseNull(Row("Sleeves SupplierID"), 0))
                Me.cboShippingPlasticSupplier.SelectedValue = CInt(IsDbaseNull(Row("Shipping Plastic SupplierID"), 0))
                Me.cboPOFSupplier.SelectedValue = CInt(IsDbaseNull(Row("POF SupplierID"), 0))
                Me.cboPolyBagSupplier.SelectedValue = CInt(IsDbaseNull(Row("Polybag SupplierID"), 0))
                Me.cboBubblesSupplier.SelectedValue = CInt(IsDbaseNull(Row("Bubbles SupplierID"), 0))
                Me.cboShippingBoxSupplier.SelectedValue = CInt(IsDbaseNull(Row("Shipping Box SupplierID"), 0))
                Me.cboRetailBoxSupplier.SelectedValue = CInt(IsDbaseNull(Row("Retail Box SupplierID"), 0))
                Me.cboLiner1Supplier.SelectedValue = CInt(IsDbaseNull(Row("Liner1 SupplierID"), 0))
                Me.cboLiner1Supplier.SelectedValue = CInt(IsDbaseNull(Row("Liner2 SupplierID"), 0))
                Me.cboPadsSupplier.SelectedValue = CInt(IsDbaseNull(Row("Pads SupplierID"), 0))
                Me.cboFilledEmp1.SelectedValue = CInt(IsDbaseNull(Row("FilledEmp1ID"), 0))
                Me.cboFilledEmp2.SelectedValue = CInt(IsDbaseNull(Row("FilledEmp2ID"), 0))
                Me.cboFilledEmp3.SelectedValue = CInt(IsDbaseNull(Row("FilledEmp3ID"), 0))
                Me.cboFilledEmp4.SelectedValue = CInt(IsDbaseNull(Row("FilledEmp4ID"), 0))
                Me.cboMixedEmp.SelectedValue = CInt(IsDbaseNull(Row("MixedEmpID"), 0))
                Me.cboSealedEmp.SelectedValue = CInt(IsDbaseNull(Row("SealedEmpID"), 0))

         End If
     End Sub


  6. RJ
    RJ avatar
    384 posts
    Member since:
    Oct 2006

    Posted 07 Dec 2012 Link to this post

    Got the solution for Q2 2012...
    Its a RadDropdownList Bug if your going to use it like this:
    RadDDL.DataSource = DT
    RadDDL.DisplayMember = "Text"
    RadDDL.ValueMember = "ID"

    Setting RadDDL.SelectedValue = ID value wont work :

    But if you populate your RadDropdownList by RadLIstDataItem like this:
    Dim ObjListItem As RadListDataItem
    ObjListItem = New RadListDataItem("Text", 1)

    Setting RadDDL.SelectedValue = ID value will work :
  7. Peter
    Peter avatar
    1148 posts

    Posted 07 Dec 2012 Link to this post


    Thank you for contacting Telerik support.

    You should set the SelectedValue exactly to the same type as the ValueMember column. For example, if the ValueMember column is of type Short and you set the SelectedValue to 15 which is Integer, RadListDataSource cannot find matches between the types and the SelectedValue fails. 
    'not correct
    radDropDownList.SelectedValue = 15
    radDropDownList.SelectedValue = short(15)

    I hope this helps Greetings,
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Back to Top
DevCraft banner