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

CheckedDropDownList with Databound list with default checked items issue

4 Answers 400 Views
CheckedDropDownList
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Mark asked on 25 Oct 2017, 01:56 PM

I have a RadCheckedDropDownList that I am binding a BindingList to it. Some of the items in the list will have the CheckedMember property filled in. However, after the control loads, the items that are checked do not show up in TEXT area of the control. However, if you open the dropdown, you can see items checked.  As soon as you uncheck or check an item, all the checked items do show up.  This is a problem, I need the items that are checked by default to show up in the TEXT area.  Below is my code that I use to bind my list to the control.  Am I missing something?


private static void BindList (this RadCheckedDropDownList radDropDownList, BindingList<CheckedListItem> dropDownList, string valueMember = "Key", string displayMember = "Value", string checkedMember = "Checked")  
{
radDropDownList.BeginUpdate();
radDropDownList.ValueMember = valueMember;
radDropDownList.DisplayMember = displayMember;
radDropDownList.CheckedMember = checkedMember;
radDropDownList.DataSource = dropDownList;
radDropDownList.EndUpdate();
radDropDownList.SelectedIndex = -1;
}

4 Answers, 1 is accepted

Sort by
0
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
answered on 25 Oct 2017, 02:53 PM
Ok, the solution was to remove the "BeginUpdate()" and "EndUpdate()" from my code.  
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 26 Oct 2017, 01:55 PM
Hello, Mark,

Thank you for writing.  

I am glad that the problem you were facing is now resolved. Indeed, it is necessary to remove the Begin/EndUpdate methods. Usually, they can be used in situations when you add or modify a lot of items. Thus, the UI will be refreshed only once when calling the EndUpdate method, not with each add/edit operation.

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Shanti 😎
Top achievements
Rank 2
Veteran
answered on 30 Jul 2019, 11:31 AM
I am binding a Datasource to RadCheckedDropDownList. This RadCheckedDropDownList have checked items. TextBlockFormatting not working binding time (Figure 1).
After binding i checked or unchecked item TextBlockFormatting working properly(Figure 2). I need a RadCheckedDropDownList like Figure 2..
Waiting for your favourable response.


Binding here...
RadCheckedDropDownList1.DataSource = Nothing
RadCheckedDropDownList1.CheckedMember = "vaIsProductVariant"
RadCheckedDropDownList1.DisplayMember = "ProductVariantValueID"
RadCheckedDropDownList1.ValueMember = "VariantValue"
RadCheckedDropDownList1.DataSource = value


Formatting Code....
Private Sub chkVariantValue_TextBlockFormatting(sender As Object, e As TextBlockFormattingEventArgs) 

        Dim token As TokenizedTextBlockElement = TryCast(e.TextBlock, TokenizedTextBlockElement)

        If token IsNot Nothing Then
            token.GradientStyle = Telerik.WinControls.GradientStyles.Solid
            token.BackColor = ColorTranslator.FromHtml(TokenColor)
            token.BorderColor = ColorTranslator.FromHtml(TokenColor)
            token.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
            token.Shape = New RoundRectShape
        End If

End Sub
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 30 Jul 2019, 12:50 PM
Hello, Shanti,   

In order to obtain the property formatting of the tokens, make sure that you subscribe to the TextBlockFormatting event before binding RadCheckedDropDownList:

private void RadForm1_Load(object sender, EventArgs e)
{
    this.productsTableAdapter.Fill(this.nwindDataSet.Products);
     
    this.radCheckedDropDownList1.CheckedDropDownListElement.AutoCompleteEditableAreaElement.AutoCompleteTextBox.TextBlockFormatting += AutoCompleteTextBox_TextBlockFormatting;
 
    this.radCheckedDropDownList1.ValueMember = "ProductID";
    this.radCheckedDropDownList1.DisplayMember = "ProductName";
    this.radCheckedDropDownList1.CheckedMember = "Discontinued";
    this.radCheckedDropDownList1.DataSource = this.productsBindingSource;
}
 
private void AutoCompleteTextBox_TextBlockFormatting(object sender, Telerik.WinControls.UI.TextBlockFormattingEventArgs e)
{
    TokenizedTextBlockElement token = e.TextBlock as TokenizedTextBlockElement;
 
    if (token != null)
    {
        token.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
        token.BackColor = Color.Yellow;
        token.BorderColor = Color.Red;
    }
}

I hope this information helps. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
CheckedDropDownList
Asked by
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Answers by
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Dess | Tech Support Engineer, Principal
Telerik team
Shanti 😎
Top achievements
Rank 2
Veteran
Share this question
or