Transparent Custom Graphing User Control: Turning Black on Runtime











up vote
2
down vote

favorite
1












I have a custom graphing usercontrol which has support for transparent backcolor. During design, the usercontrol shows properly. However, on runtime, the backcolor turns black.



Chart on Runtime



I have searched stackoverflow for a solution, but most of the articles refer to WPF or controllers. :(



Things I have tried:



I have tried using a transparentpanel usercontrol to house the graphing usercontrol. This changed nothing. I set the graphing usercontrol to use the transparentpanel as the parent, nothing.



Does anybody have any input on how to prevent this from happening? Thank you.



Update 1: If I just add the graphing usercontrol to the form and run the app, the transparency still works. It seems to be an issue when it starts graphing. I have tried the following solutions.



    protected override CreateParams CreateParams
{
get
{
CreateParams parameters = base.CreateParams;
parameters.ExStyle |= WS_EX_TRANSPARENT;
return parameters;
}
}

internal const int WS_EX_TRANSPARENT = 0x00000020;


I also tried adding:



        this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);









share|improve this question
























  • Isn't this the same issue as Transparent Overlapping Circular Progress Bars (Custom Control)
    – LarsTech
    Nov 20 at 17:06










  • I never had a problem with the transparency of the circularprogressbars to form. Just when they overlapped. This is straight up on the form.
    – frostbyte
    Nov 20 at 17:07










  • Well, what's different?
    – LarsTech
    Nov 20 at 17:08










  • Is this related to your previous question? transparentpanel usercontrol what does it mean? Is this a CustomControl or a UserControl (different stuff)? Are you setting the BackColor to Color.Transparent at some point? Post the code related to the drawing.
    – Jimi
    Nov 20 at 17:08










  • I set the graphing usercontrol to use the transparentpanel as the parent I'm guessing this is your issue. WinForms never has true transparency, just copying the background of the parent container.
    – LarsTech
    Nov 20 at 17:11

















up vote
2
down vote

favorite
1












I have a custom graphing usercontrol which has support for transparent backcolor. During design, the usercontrol shows properly. However, on runtime, the backcolor turns black.



Chart on Runtime



I have searched stackoverflow for a solution, but most of the articles refer to WPF or controllers. :(



Things I have tried:



I have tried using a transparentpanel usercontrol to house the graphing usercontrol. This changed nothing. I set the graphing usercontrol to use the transparentpanel as the parent, nothing.



Does anybody have any input on how to prevent this from happening? Thank you.



Update 1: If I just add the graphing usercontrol to the form and run the app, the transparency still works. It seems to be an issue when it starts graphing. I have tried the following solutions.



    protected override CreateParams CreateParams
{
get
{
CreateParams parameters = base.CreateParams;
parameters.ExStyle |= WS_EX_TRANSPARENT;
return parameters;
}
}

internal const int WS_EX_TRANSPARENT = 0x00000020;


I also tried adding:



        this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);









share|improve this question
























  • Isn't this the same issue as Transparent Overlapping Circular Progress Bars (Custom Control)
    – LarsTech
    Nov 20 at 17:06










  • I never had a problem with the transparency of the circularprogressbars to form. Just when they overlapped. This is straight up on the form.
    – frostbyte
    Nov 20 at 17:07










  • Well, what's different?
    – LarsTech
    Nov 20 at 17:08










  • Is this related to your previous question? transparentpanel usercontrol what does it mean? Is this a CustomControl or a UserControl (different stuff)? Are you setting the BackColor to Color.Transparent at some point? Post the code related to the drawing.
    – Jimi
    Nov 20 at 17:08










  • I set the graphing usercontrol to use the transparentpanel as the parent I'm guessing this is your issue. WinForms never has true transparency, just copying the background of the parent container.
    – LarsTech
    Nov 20 at 17:11















up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





I have a custom graphing usercontrol which has support for transparent backcolor. During design, the usercontrol shows properly. However, on runtime, the backcolor turns black.



Chart on Runtime



I have searched stackoverflow for a solution, but most of the articles refer to WPF or controllers. :(



Things I have tried:



I have tried using a transparentpanel usercontrol to house the graphing usercontrol. This changed nothing. I set the graphing usercontrol to use the transparentpanel as the parent, nothing.



Does anybody have any input on how to prevent this from happening? Thank you.



Update 1: If I just add the graphing usercontrol to the form and run the app, the transparency still works. It seems to be an issue when it starts graphing. I have tried the following solutions.



    protected override CreateParams CreateParams
{
get
{
CreateParams parameters = base.CreateParams;
parameters.ExStyle |= WS_EX_TRANSPARENT;
return parameters;
}
}

internal const int WS_EX_TRANSPARENT = 0x00000020;


I also tried adding:



        this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);









share|improve this question















I have a custom graphing usercontrol which has support for transparent backcolor. During design, the usercontrol shows properly. However, on runtime, the backcolor turns black.



Chart on Runtime



I have searched stackoverflow for a solution, but most of the articles refer to WPF or controllers. :(



Things I have tried:



I have tried using a transparentpanel usercontrol to house the graphing usercontrol. This changed nothing. I set the graphing usercontrol to use the transparentpanel as the parent, nothing.



Does anybody have any input on how to prevent this from happening? Thank you.



Update 1: If I just add the graphing usercontrol to the form and run the app, the transparency still works. It seems to be an issue when it starts graphing. I have tried the following solutions.



    protected override CreateParams CreateParams
{
get
{
CreateParams parameters = base.CreateParams;
parameters.ExStyle |= WS_EX_TRANSPARENT;
return parameters;
}
}

internal const int WS_EX_TRANSPARENT = 0x00000020;


I also tried adding:



        this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);






c# winforms user-controls transparency graphing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 16:57

























asked Nov 20 at 16:46









frostbyte

325412




325412












  • Isn't this the same issue as Transparent Overlapping Circular Progress Bars (Custom Control)
    – LarsTech
    Nov 20 at 17:06










  • I never had a problem with the transparency of the circularprogressbars to form. Just when they overlapped. This is straight up on the form.
    – frostbyte
    Nov 20 at 17:07










  • Well, what's different?
    – LarsTech
    Nov 20 at 17:08










  • Is this related to your previous question? transparentpanel usercontrol what does it mean? Is this a CustomControl or a UserControl (different stuff)? Are you setting the BackColor to Color.Transparent at some point? Post the code related to the drawing.
    – Jimi
    Nov 20 at 17:08










  • I set the graphing usercontrol to use the transparentpanel as the parent I'm guessing this is your issue. WinForms never has true transparency, just copying the background of the parent container.
    – LarsTech
    Nov 20 at 17:11




















  • Isn't this the same issue as Transparent Overlapping Circular Progress Bars (Custom Control)
    – LarsTech
    Nov 20 at 17:06










  • I never had a problem with the transparency of the circularprogressbars to form. Just when they overlapped. This is straight up on the form.
    – frostbyte
    Nov 20 at 17:07










  • Well, what's different?
    – LarsTech
    Nov 20 at 17:08










  • Is this related to your previous question? transparentpanel usercontrol what does it mean? Is this a CustomControl or a UserControl (different stuff)? Are you setting the BackColor to Color.Transparent at some point? Post the code related to the drawing.
    – Jimi
    Nov 20 at 17:08










  • I set the graphing usercontrol to use the transparentpanel as the parent I'm guessing this is your issue. WinForms never has true transparency, just copying the background of the parent container.
    – LarsTech
    Nov 20 at 17:11


















Isn't this the same issue as Transparent Overlapping Circular Progress Bars (Custom Control)
– LarsTech
Nov 20 at 17:06




Isn't this the same issue as Transparent Overlapping Circular Progress Bars (Custom Control)
– LarsTech
Nov 20 at 17:06












I never had a problem with the transparency of the circularprogressbars to form. Just when they overlapped. This is straight up on the form.
– frostbyte
Nov 20 at 17:07




I never had a problem with the transparency of the circularprogressbars to form. Just when they overlapped. This is straight up on the form.
– frostbyte
Nov 20 at 17:07












Well, what's different?
– LarsTech
Nov 20 at 17:08




Well, what's different?
– LarsTech
Nov 20 at 17:08












Is this related to your previous question? transparentpanel usercontrol what does it mean? Is this a CustomControl or a UserControl (different stuff)? Are you setting the BackColor to Color.Transparent at some point? Post the code related to the drawing.
– Jimi
Nov 20 at 17:08




Is this related to your previous question? transparentpanel usercontrol what does it mean? Is this a CustomControl or a UserControl (different stuff)? Are you setting the BackColor to Color.Transparent at some point? Post the code related to the drawing.
– Jimi
Nov 20 at 17:08












I set the graphing usercontrol to use the transparentpanel as the parent I'm guessing this is your issue. WinForms never has true transparency, just copying the background of the parent container.
– LarsTech
Nov 20 at 17:11






I set the graphing usercontrol to use the transparentpanel as the parent I'm guessing this is your issue. WinForms never has true transparency, just copying the background of the parent container.
– LarsTech
Nov 20 at 17:11














1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










I had a similar problem to this. I searched Google and found my answer. I don't know your code for your custom control, but take a look for a line like this in your OnPaint:



e.Graphics.Clear(Color.Transparent);


The function "Clear" used with the "Transparent" color is not going to make your custom control transparent. It essentially paints the color transparent over your entire control. This can lead to some pretty funky results.






share|improve this answer

















  • 1




    This is exactly what the problem was. Wow. Thank you so much for your help. Problem solved.
    – frostbyte
    Nov 20 at 19:26













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53397705%2ftransparent-custom-graphing-user-control-turning-black-on-runtime%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










I had a similar problem to this. I searched Google and found my answer. I don't know your code for your custom control, but take a look for a line like this in your OnPaint:



e.Graphics.Clear(Color.Transparent);


The function "Clear" used with the "Transparent" color is not going to make your custom control transparent. It essentially paints the color transparent over your entire control. This can lead to some pretty funky results.






share|improve this answer

















  • 1




    This is exactly what the problem was. Wow. Thank you so much for your help. Problem solved.
    – frostbyte
    Nov 20 at 19:26

















up vote
1
down vote



accepted










I had a similar problem to this. I searched Google and found my answer. I don't know your code for your custom control, but take a look for a line like this in your OnPaint:



e.Graphics.Clear(Color.Transparent);


The function "Clear" used with the "Transparent" color is not going to make your custom control transparent. It essentially paints the color transparent over your entire control. This can lead to some pretty funky results.






share|improve this answer

















  • 1




    This is exactly what the problem was. Wow. Thank you so much for your help. Problem solved.
    – frostbyte
    Nov 20 at 19:26















up vote
1
down vote



accepted







up vote
1
down vote



accepted






I had a similar problem to this. I searched Google and found my answer. I don't know your code for your custom control, but take a look for a line like this in your OnPaint:



e.Graphics.Clear(Color.Transparent);


The function "Clear" used with the "Transparent" color is not going to make your custom control transparent. It essentially paints the color transparent over your entire control. This can lead to some pretty funky results.






share|improve this answer












I had a similar problem to this. I searched Google and found my answer. I don't know your code for your custom control, but take a look for a line like this in your OnPaint:



e.Graphics.Clear(Color.Transparent);


The function "Clear" used with the "Transparent" color is not going to make your custom control transparent. It essentially paints the color transparent over your entire control. This can lead to some pretty funky results.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 at 19:23









Alexandra

264




264








  • 1




    This is exactly what the problem was. Wow. Thank you so much for your help. Problem solved.
    – frostbyte
    Nov 20 at 19:26
















  • 1




    This is exactly what the problem was. Wow. Thank you so much for your help. Problem solved.
    – frostbyte
    Nov 20 at 19:26










1




1




This is exactly what the problem was. Wow. Thank you so much for your help. Problem solved.
– frostbyte
Nov 20 at 19:26






This is exactly what the problem was. Wow. Thank you so much for your help. Problem solved.
– frostbyte
Nov 20 at 19:26




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53397705%2ftransparent-custom-graphing-user-control-turning-black-on-runtime%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'