We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Caption Paint Event

Thread ID:

Created:

Updated:

Platform:

Replies:

131136 Jun 22,2017 04:05 PM UTC Jun 27,2017 04:49 AM UTC WinForms 3
loading
Tags: MetroForm
JSpencer
Asked On June 22, 2017 04:05 PM UTC

Hello,

I want to be able to dynamically change the color(s) of the caption bar background and the caption image.

Usually I would hook into the Paint event but these do not seem to be exposed.

For example I want to be able to do something like:


private void FormCaptionPanel_Paint(object sender, PaintEventArg e)
{
var colorA = Color.White;
var colorB = Color.Black;
var gradientFillStyle = LinearGradientMode.Vertical;
var gradientBrush = new LinearGradientBrush(ClientRectangle, colorA, colorB, gradientFillStyle);
e.Graphics.FillRectangle(gradientBrush, ClientRectangle);
}

And call it somehow like this:
this.captionPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.FormCaptionPanel_Paint);

But the MetroForm doesn't seem to have these methods exposed. Is there anyway I can override these?

I am trying to do something similar for the Caption bar Image as well where I want to hook into the paint event but again this isn't exposed.

Thanks,


Vijayalakshmi Roopkumar [Syncfusion]
Replied On June 23, 2017 07:17 AM UTC

Hi Jacob

Thank you for contacting Syncfusion Support.

We have prepared the sample that tries to meet your requirement. In order to change the Background of the CaptionBar and Caption Images of MetroForm dynamically, you can use the CaptionBarColor property of MetroForm and Backcolor property of CaptionImage class. Please find the code for the same from below:  
Code Example:[C#] 
   
// To Customize background color of CaptionBar dynamically   
this.CaptionBarColor = Color.Yellow;   
   
   
 
  
Code Example:[C#] 
   
foreach (CaptionImage image in this.CaptionImages)   
{   
// To Customize background color of CaptionImage dynamically   
image.BackColor = Color.Green ;   
}   
   
  
Screenshot: 
  
  
Screenshot shows the Backcolor applied for the CaptionImage after clicking the button: 
  
  
Screenshot shows the Backcolor applied for the CaptionBar after clicking the button. 
   
  

So we suggest you to use this property to change the desired color of CaptionBar and CaptionImage in MetroForm instead of hooking the paint event. Please check this sample and let us know if it helps you.

This above scenario is just an example. Kindly refer with Syncfusion Dashboard sample in below location for your further reference.

Sample Path: Syncfusion\EssentialStudio\[Installed Version]\Windows\Tools.Windows\Samples\Metro Style\Metro Style Controls \CS

Regards,
Vijayalakshmi V.R.  


JSpencer
Replied On June 23, 2017 08:19 AM UTC

Hello,


Thanks for this.


I am aware of how to change the caption bar color like that.

The reasons why I wanted to hook into the paint event was to create a gradient effect on the caption bar, is this possible?


Vijayalakshmi Roopkumar [Syncfusion]
Replied On June 27, 2017 04:49 AM UTC

Hi Jacob

We would like to inform you that MetroForm don’t have the reported support to expose the paint event currently. A support incident has been created under your account to track the status of this reported requirement. Please log on to our support website to check for further updates

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents 

Please let me know if you have any questions.

Regards,
Vijayalakshmi V.R. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;