Profile Picture

NExpander header background color

Posted By Imanol Yurrebaso 11 Years Ago
Author
Message
Imanol Yurrebaso
Posted 11 Years Ago
View Quick Profile
Junior Member

Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)

Group: Forum Members
Last Active: 8 Years Ago
Posts: 15, Visits: 3
Hello there,

I'm using some NExpander items in my program, and most of the times I have them vertically placed in a window. As I wanted to help the user differentiate between them, I tried to modify the background color of the headers of the NExpanders. But I can't find the proper method to do so. As far as I understand:

- "NExpander.HeaderFont" is only used for the font of the text inside the header.
- "NExpander.HeaderBackground" should be the one, but it is asking for a 'segmented image'

There are still a lot of things that I must learn about C#... am I supposed to override a method or something like that? I would appreciate all the help.

Thanks in advance.

Nevron Support
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hello Imanol,

To change the background color of the NExpander's header you need to set ControlDark and ControlLight properties of its Palette.
NExpander.Palette.ControlLight color is also used for the background of the expander's back color, so you need to consider this too.

Also, you need to set PaletteInheritance property to None in order to prevent the control to inherit Palette form its parent.

Best Regards,
Nevron Support Team



Imanol Yurrebaso
Posted 11 Years Ago
View Quick Profile
Junior Member

Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)

Group: Forum Members
Last Active: 8 Years Ago
Posts: 15, Visits: 3
Thanks for the fast reply.

When I try something like this:

dynamicExpander.PaletteInheritance = PaletteInheritance.None;
dynamicExpander.Palette.ControlLight = Color.Blue;
dynamicExpander.Palette.ControlDark = Color.LightGray;

It only affects the content of the expander. For example, the header row of a DataGrid I have inside of the NExpander takes the Blue color, but not the header of the NExpander itself. And the LightGray is applied to the background inside of the NExpander. What am I doing wrong?

Nevron Support
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hello Imanol,

If you have an old version please try the following:

dynamicExpander.Palette.ColorTable.ControlLight = new NColorInfo(Color.Blue);
dynamicExpander.Palette.ColorTable.ControlDark = new NColorInfo(Color.LightGray);



Best Regards,
Nevron Support Team



Imanol Yurrebaso
Posted 11 Years Ago
View Quick Profile
Junior Member

Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)

Group: Forum Members
Last Active: 8 Years Ago
Posts: 15, Visits: 3
I should have told that the version we are working with is "9.11.3.12", I don't know how old is that.

I am not allowed to do this...

dynamicExpander.Palette.ColorTable.ControlLight = new NColorInfo(Color.Blue);

... as dynamicExpander.Palette.ColorTable.ControlLight is not a NColorInfo, but a Color. Still, even if I do this (EDIT: I copied the same line as above, this is what I meant)...

dynamicExpander.Palette.ColorTable.ControlLight = Color.Blue;

.. there is no visible effect.

Let me write the chunk of code where I set the NExpander properties:

/***********Begin***************/

NExpander dynamicExpander = new NExpander();
dynamicExpander.AnimationInfo.Fade = true;
dynamicExpander.AnimationInfo.Hide = false;
dynamicExpander.AnimationInfo.Scroll = false;
dynamicExpander.AnimationInfo.Slide = true;
dynamicExpander.AnimationInfo.Steps = 2;
dynamicExpander.Text = "whatever";
dynamicExpander.Name = "whatever";
dynamicExpander.Dock = System.Windows.Forms.DockStyle.Top;
dynamicExpander.HeaderFont = new Font("Arial", 10.0f, FontStyle.Bold);
dynamicExpander.HeaderImage = TreeIcons.Images[8];
dynamicExpander.FocusRect = false;
dynamicExpander.DrawBorder = true;
dynamicExpander.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(214)), ((System.Byte)(223)), ((System.Byte)(247)));
dynamicExpander.Palette.BaseScheme = Nevron.UI.WinForm.Controls.ColorScheme.VistaPlus;
dynamicExpander.Palette.ControlBorder = System.Drawing.SystemColors.ActiveCaptionText;
dynamicExpander.Palette.ControlText = System.Drawing.SystemColors.ActiveCaptionText;
dynamicExpander.PaletteInheritance = Nevron.UI.WinForm.Controls.PaletteInheritance.None;
dynamicExpander.Palette.ColorTable.ControlLight = new NColorInfo(Color.Blue);
dynamicExpander.Palette.ColorTable.ControlDark = new NColorInfo(Color.LightGray);

dynamicExpander.Controls.Add(nDGVnewClass); //nDGVnewClass is a DataGridView

nTabGeneral.Controls.Add(dynamicExpander);

/***********End***************/


Is there something else that is overwriting the color parameters?

This is not a critical problem for us, but it would be nice if we could change it. Thank you.

Nevron Support
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hello Imanol,

In the version you have this feature is not presented yet.
You can either get the latest version or subclass NExpanderRenderer class to implement this functionality.
Here is an example implementation which uses the mentioned Colors defined in the Palette property.

public class MyNExpanderRenderer : NExpanderRenderer
   {
      protected override void DrawHeaderBackground(Graphics g)
      {
         if(m_Expander == null)
            return;

         NRectangle r = m_Expander.ElementBounds;

         Color c1 = Palette.ControlLight;
         Color c2 = Palette.ControlDark;

         LinearGradientBrush br = new LinearGradientBrush(r.ToRectangle(), c1, c2, 0.0f);
         GraphicsPath headerPath = GetHeaderPath();
         g.FillPath(br, headerPath);

         br.Dispose();

         if (!m_Expander.DrawBorder)
            return;

         SmoothingMode mode = g.SmoothingMode;
         g.SmoothingMode = SmoothingMode.AntiAlias;

         Color border = Palette.ControlBorder;
         Pen p = new Pen(border);
         g.DrawPath(p, headerPath);

         g.SmoothingMode = mode;
         p.Dispose();

      }

      public NExpander Owner
      {
         get
         {
            return m_Expander;
         }
         set
         {
            m_Expander = value;
         }
      }

      NExpander m_Expander;
   }

You will also need to create an instance of this class set Owner property to the expander and set Renderer property of the expander to the instance.

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic