Hi I have a Forms application that uses a custom control based on a Track bar called colorSlider. This control was obtained from code project and added to the tools in VS2017. All aspects of the control work fine. I can change any properties as I wish. However, the final project is quite large and all of the track bars (50 or so) will be replaced with this custom control. I also want to be able to modify the look and feel of the sliders with user customization skins. So, here is a typical command to change button on the slider.
colorSlider1.ThumbInnerColor = Color.FromArgb(99, 130, 208);
And this works perfectly fine. However I want to do this in a loop. All controls are on a panel called backpanel. Here is an example for changing the forecolor of a button:
foreach (Panel pnl in backPanel.Controls)
{
foreach (Control c in pnl.Controls)
{
if (c is Button)
{
c.ForeColor = Color.Black;
}
}
}
This works great. However, if I try this:
foreach (Panel pnl in backPanel.Controls)
{
foreach (Control c in pnl.Controls)
{
if (c is ColorSlider.ColorSlider)
{
c.ThumbInnerColor = Color.FromArgb(99, 130, 208);
}
}
}
In this case visual studio gives a syntax error
Error CS1061 'Control' does not contain a definition for 'ThumbInnerColor' and no accessible extension method 'ThumbInnerColor' accepting a first argument of type 'Control' could be found (are you missing a using directive or an assembly reference?)
So anyone have an idea on how to fix this? Thanks
or in newer C#
foreach (Panel pnl in backPanel.Controls)
{
foreach (Control c in pnl.Controls)
{
if (c is ColorSlider.ColorSlider s)
{
s.ThumbInnerColor = Color.FromArgb(99, 130, 208);
}
}
}