RadColorBox BindingSource

2 posts, 0 answers
  1. Mohamed
    Mohamed avatar
    1 posts
    Member since:
    Jan 2015

    Posted 31 May 2015 Link to this post

    how can i use a binding source to bind values to radColorBox  while binding source is list of string of color names
  2. Dimitar
    Dimitar avatar
    2949 posts

    Posted 01 Jun 2015 Link to this post

    Hi Mohamed,

    Thank you for writing.

    You should create a Binding and use it Format and Parse events to convert from String to Color and vice versa. For example:
    public partial class RadForm1 : Telerik.WinControls.UI.RadForm
        public RadForm1()
            BindingList<ColorInfo> colorNames = new BindingList<ColorInfo>();
            colorNames.Add(new ColorInfo() { ColorName = "Red" });
            colorNames.Add(new ColorInfo() { ColorName = "Green" });
            colorNames.Add(new ColorInfo() { ColorName = "Blue" });
            BindingSource source = new BindingSource();
            source.DataSource = colorNames;
            radBindingNavigator1.BindingSource = source;    
            Binding binding = new Binding("Value", source, "ColorName", true);
            binding.Format += binding_Format;
            binding.Parse += binding_Parse;
        void binding_Format(object sender, ConvertEventArgs e)
            string val = e.Value.ToString();
            switch (val)
                case "Red":
                    e.Value = Color.Red;
                case "Blue":
                    e.Value = Color.Blue;
                case "Green":
                    e.Value = Color.Green;
                    e.Value = Color.FromArgb(int.Parse(e.Value.ToString()));
        void binding_Parse(object sender, ConvertEventArgs e)
            e.Value = ((Color)e.Value).ToArgb().ToString();
    class ColorInfo
        public string ColorName { get; set; }

    I hope this will be useful.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top