NExpander header background color


Author
Message
Imanol Yurrebaso
Imanol Yurrebaso
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
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.
Reply
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
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


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search