Hi,
I am trying to find a way to add a color picker to a ribbon group. I couldn't find the color picker control as such.
Could someone help me in this regard?
I am using RadControls for WinForms Q3 2010.
I am trying to find a way to add a color picker to a ribbon group. I couldn't find the color picker control as such.
Could someone help me in this regard?
I am using RadControls for WinForms Q3 2010.
12 Answers, 1 is accepted
0
Richard Slade
Top achievements
Rank 2
answered on 31 Mar 2011, 10:50 AM
Hello Jack,
As far as I'm aware, there is no colour picker as per the one in your screenshot. However, if you go to the demos n your PC and look at the RibbonBar >> First Look one, then there is an exmaple of showing a colour pallette with an Edit Colours section that launches the RadColorDialog. This RadColorDialog can also be seen in full in the demos under Forms & Dialogs >> Color Dialog
Hope that helps
Richard
As far as I'm aware, there is no colour picker as per the one in your screenshot. However, if you go to the demos n your PC and look at the RibbonBar >> First Look one, then there is an exmaple of showing a colour pallette with an Edit Colours section that launches the RadColorDialog. This RadColorDialog can also be seen in full in the demos under Forms & Dialogs >> Color Dialog
Hope that helps
Richard
0
Jack
Top achievements
Rank 1
answered on 31 Mar 2011, 04:07 PM
Hi Richard,
Thanks for the reply but I was looking for something similar to the one in MS word. I did look at the color dialog in the examples but will use it in the worst case scenario.
Thanks for the reply but I was looking for something similar to the one in MS word. I did look at the color dialog in the examples but will use it in the worst case scenario.
0
Richard Slade
Top achievements
Rank 2
answered on 31 Mar 2011, 04:49 PM
Hi Jack,
There is one that someone has created here but this is not supported in any way by Telerik.
Hope that helps
Richard
There is one that someone has created here but this is not supported in any way by Telerik.
Hope that helps
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 31 Mar 2011, 05:25 PM
Hi,
I've got a couple of ideas, but not sure if it will work. I'll let you know if I can get something working for you.
Richard
I've got a couple of ideas, but not sure if it will work. I'll let you know if I can get something working for you.
Richard
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 31 Mar 2011, 08:29 PM
Hi again Jack,
Ok, I've managed to put something together for you. It's not exactly like the Microsoft one, but it seems to do the job pretty well.
The concept is based on an inherited RadSplitButton, and then adding in a Menu Item that contains a panel. In the panel I have added the standard RadColorDialogForm and then resized everything to make it look a little neater.
The new RadDropDownColorPicker looks like a standard RadSplitButton and you can add an image of course to the button to make it look more like you need to. I have made a small video of the functionality which you can find here
The code probably needs a bit of a tidy up, but it's all here
RadDropDownColorPicker.vb
Example Usage (Form1.vb)
I hope this helps. If you find it good enough, then I might submit it as a Code Library project in both VB and C#.
Regards,
Richard
Ok, I've managed to put something together for you. It's not exactly like the Microsoft one, but it seems to do the job pretty well.
The concept is based on an inherited RadSplitButton, and then adding in a Menu Item that contains a panel. In the panel I have added the standard RadColorDialogForm and then resized everything to make it look a little neater.
The new RadDropDownColorPicker looks like a standard RadSplitButton and you can add an image of course to the button to make it look more like you need to. I have made a small video of the functionality which you can find here
The code probably needs a bit of a tidy up, but it's all here
RadDropDownColorPicker.vb
Imports Telerik.WinControls.UI Imports Telerik.WinControls Public Class RadDropDownColorPicker Inherits RadSplitButton Private m_CurrentColor As System.Drawing.Color = Color.Black Private m_Form As RadColorDialogForm Private m_Panel As RadPanel Public Event ColorChanged As EventHandler(Of ColorChangedEventArgs) Public Sub New() MyBase.New() Me.DropDownButtonElement.ArrowButton.Fill.BackColor = m_CurrentColor Me.DropDownButtonElement.ArrowButton.Fill.NumberOfColors = 1 m_Panel = New RadPanel() Dim item As New RadMenuItem() item.MaxSize = New Size(508, 395) Me.Items.Add(item) AddHandler Me.DropDownButtonElement.DropDownMenu.PopupOpened, AddressOf DropDown_PopUpOpened End Sub Public Property CurrentColor As System.Drawing.Color Get Return m_CurrentColor End Get Set(value As System.Drawing.Color) m_CurrentColor = value Me.DropDownButtonElement.ArrowButton.Fill.BackColor = m_CurrentColor RaiseEvent ColorChanged(Me, New ColorChangedEventArgs(m_CurrentColor)) End Set End Property Private Sub DropDown_PopUpOpened(sender As Object, args As EventArgs) Me.DropDownButtonElement.DropDownMenu.PopupElement.MaxSize = New Size(508, 395) Me.Items.Clear() m_Panel.Size = New Size(508, 395) m_Form = New RadColorDialogForm() m_Form.SelectedColor = m_CurrentColor m_Form.OldColor = m_CurrentColor m_Form.ShowBasicColors = False m_Form.ShowSystemColors = False m_Form.ShowWebColors = False m_Form.TopLevel = False AddHandler m_Form.FormClosing, AddressOf ColorForm_Closing m_Form.FormBorderStyle = Windows.Forms.FormBorderStyle.None m_Panel.Controls.Add(m_Form) m_Form.Show() Dim item As New RadMenuItem() item.AutoSize = False item.BackColor = Color.Transparent item.Size = m_Panel.Size item.Alignment = ContentAlignment.MiddleCenter item.Children.Add(New RadHostItem(m_Panel)) Me.Items.Add(item) End Sub Private Sub ColorForm_Closing(sender As Object, e As FormClosingEventArgs) CurrentColor = CType(sender, RadColorDialogForm).SelectedColor Me.DropDownButtonElement.DropDownMenu.ClosePopup(RadPopupCloseReason.ParentClosed) Me.DropDownButtonElement.ArrowButton.Fill.BackColor = m_CurrentColor RemoveHandler m_Form.FormClosing, AddressOf ColorForm_Closing End Sub Public Overrides Property ThemeClassName As String Get Return GetType(RadSplitButton).FullName End Get Set(value As String) End Set End Property End ClassExample Usage (Form1.vb)
Imports Telerik.WinControls Imports Telerik.WinControls.UI Public Class Form1 Private Sub RadDropDownColorPicker1_ColorChanged(sender As System.Object, e As Telerik.WinControls.ColorChangedEventArgs) Handles RadDropDownColorPicker1.ColorChanged Me.RadLabel1.ForeColor = e.SelectedColor End Sub End ClassI hope this helps. If you find it good enough, then I might submit it as a Code Library project in both VB and C#.
Regards,
Richard
0
Jack
Top achievements
Rank 1
answered on 31 Mar 2011, 10:36 PM
Hi Richard,
Sorry for the delayed response. I am in the process of testing it out. Will update you asap.
Thanks a lot for your help.
Sorry for the delayed response. I am in the process of testing it out. Will update you asap.
Thanks a lot for your help.
0
Richard Slade
Top achievements
Rank 2
answered on 31 Mar 2011, 10:50 PM
You're welcome Jack. Look forward to hearing back from you
Richard
Richard
0
Jack
Top achievements
Rank 1
answered on 31 Mar 2011, 10:52 PM
Hi Richard,
Thank you. It worked like a charm. I added the control to a form and was able to use it but looks like a ribbon group can allow only buttonelements and not buttons as such. So, I was not able to add this control to the ribbongroup which is where I actually want to add.
I tried to make some changes to your code by inheriting from the RadSplitButtonElement but was not successful in handling the DropDownButtonElement property. I couldn't find this property in the RadSplitButtonElement class.
Please advise me in this regard.
Thank you. It worked like a charm. I added the control to a form and was able to use it but looks like a ribbon group can allow only buttonelements and not buttons as such. So, I was not able to add this control to the ribbongroup which is where I actually want to add.
I tried to make some changes to your code by inheriting from the RadSplitButtonElement but was not successful in handling the DropDownButtonElement property. I couldn't find this property in the RadSplitButtonElement class.
Please advise me in this regard.
0
Jack
Top achievements
Rank 1
answered on 31 Mar 2011, 11:23 PM
Hi Richard,
Just read about the button element which I think I should have done much earlier. But anyways, as I understand the RadSplitButtonElement is itself the DropDownButtonElement and I can access the ArrowButton, DropDownMenu etc properties in it.
Was not able to access these properties earlier for some reason, so was a bit confused.
Everything just works perfectly as I was able to add the RadDropDownColorPicker to the ribbon group.
Thanks again.
Just read about the button element which I think I should have done much earlier. But anyways, as I understand the RadSplitButtonElement is itself the DropDownButtonElement and I can access the ArrowButton, DropDownMenu etc properties in it.
Was not able to access these properties earlier for some reason, so was a bit confused.
Everything just works perfectly as I was able to add the RadDropDownColorPicker to the ribbon group.
Thanks again.
0
Richard Slade
Top achievements
Rank 2
answered on 31 Mar 2011, 11:30 PM
You're welcome Jack. I'm glad that this helped you out.
All the best
Richard
All the best
Richard
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 04 Apr 2011, 11:06 AM
Hello Jack,
Just to let you know there is a slightly improved version in both C# and VB now available in this code library article
All the best
Richard
Just to let you know there is a slightly improved version in both C# and VB now available in this code library article
All the best
Richard
0
Jack
Top achievements
Rank 1
answered on 04 Apr 2011, 03:39 PM
Thanks Richard.