This is a migrated thread and some comments may be shown as answers.
Add ColorItems with C#
4 Answers 93 Views
This is a migrated thread and some comments may be shown as answers.
Martijn
Top achievements
Rank 1
Martijn asked on 25 Apr 2007, 11:31 AM
I would like to add colors using C# instead of adding colors with APSX. I`ve found the methode for a colorRange:
ColorPickerID.Items.AddRange(
    ColorPickerID.GetStandardColors()
    );  

So addin a single color wouldn`t seem difficult:
ColorPickerID.Items.Add(ColorPickerID 'coloritem'); 
But I don`t know what to fill in for 'coloritem' to add a color, preferred a hex-value.

Anyone knows the right syntax?

4 Answers, 1 is accepted

Sort by
0
Johan
Top achievements
Rank 1
answered on 25 Apr 2007, 11:47 AM
You may try something similar to:

ColorPickerID.Items.Add(new ColorPickerItem(ColorTranslator.FromHtml("#FFFF0000")));.
0
Johan
Top achievements
Rank 1
answered on 25 Apr 2007, 11:52 AM
ColorTranslator is in the System.Drawing namespace btw, so you may need to add it as well, e.g. using System.Drawing
0
Martijn
Top achievements
Rank 1
answered on 25 Apr 2007, 11:56 AM

using System.Drawing is always included when a new ASPX file is created. But thanx for the markup.

I`ve found the right syntax:

ColorPickerID.Items.Add(  
    new Telerik.Web.UI.ColorPickerItem(  
       ColorTranslator.FromHtml("#FFFF0000")  
    )  
); 
0
Todd Anglin
Top achievements
Rank 2
answered on 25 Apr 2007, 05:02 PM
Martijntijn-

You may also consider adding a "using Telerik.Web.UI" to your code if you're going to be doing a lot server side to make your code easier to read and to save you from typing the fully qualified type each time you add a color.

Thanks~
Todd
Asked by
Martijn
Top achievements
Rank 1
Answers by
Johan
Top achievements
Rank 1
Martijn
Top achievements
Rank 1
Todd Anglin
Top achievements
Rank 2
Share this question
or