Changing Font colour (VB.net)










0














i'm trying to change the font colour of the text on a desktop ticker.



This is the code i currently have:



Private Sub loadthenews()
str = ""
myArray.Clear()
fo = New Font("CALIBRI", 18, FontStyle.Bold, GraphicsUnit.Point)
Dim readXML As New XmlTextReader(Directory.GetCurrentDirectory & "news.xml")


How can i change the colour to something non standard i.e. a HEX or RGB colour.



Thank you



Edit....



I'm looking here:



Private Sub Form1_Paint(ByVal sender As Object, ByVal e As 
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
SetStyle(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.OptimizedDoubleBuffer Or _
ControlStyles.UserPaint, True)
e.Graphics.Clear(Me.BackColor)
e.Graphics.DrawString(str, fo, Brushes.Black, widthX, heightY + 5)


However i need to change the brushes colour from Black to a Hex or RGB color.
Any ideas?



Thanks in advance










share|improve this question



















  • 1




    Font objects don't have a colour. The colour the text appears in is specified elsewhere, e.g. the ForeColor of a control or via a Brush when calling Graphics.DrawString. You need to find where that colour is set in your specific case and set it there.
    – jmcilhinney
    Nov 12 at 10:56






  • 1




    See which control is used to output the XML content. That control has a ForeColor property. If the text is instead drawn on a control surface (this is something that is relatively common when building a marquee-like control or using a standard control class (TextBox, Label) as a marquee), the Paint() event of that control should have created a Brush object with a specific Color.
    – Jimi
    Nov 12 at 11:40











  • Updated question, thank you both for the help so far!
    – Scott McCubbin
    Nov 12 at 13:06











  • Move that SetStyle() call out of the Paint() event ASAP. That one goes in the Form's (or any other class) Constructor (Sub New()).
    – Jimi
    Nov 12 at 14:29











  • Thanks for all the help, this is now working
    – Scott McCubbin
    Nov 12 at 15:07















0














i'm trying to change the font colour of the text on a desktop ticker.



This is the code i currently have:



Private Sub loadthenews()
str = ""
myArray.Clear()
fo = New Font("CALIBRI", 18, FontStyle.Bold, GraphicsUnit.Point)
Dim readXML As New XmlTextReader(Directory.GetCurrentDirectory & "news.xml")


How can i change the colour to something non standard i.e. a HEX or RGB colour.



Thank you



Edit....



I'm looking here:



Private Sub Form1_Paint(ByVal sender As Object, ByVal e As 
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
SetStyle(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.OptimizedDoubleBuffer Or _
ControlStyles.UserPaint, True)
e.Graphics.Clear(Me.BackColor)
e.Graphics.DrawString(str, fo, Brushes.Black, widthX, heightY + 5)


However i need to change the brushes colour from Black to a Hex or RGB color.
Any ideas?



Thanks in advance










share|improve this question



















  • 1




    Font objects don't have a colour. The colour the text appears in is specified elsewhere, e.g. the ForeColor of a control or via a Brush when calling Graphics.DrawString. You need to find where that colour is set in your specific case and set it there.
    – jmcilhinney
    Nov 12 at 10:56






  • 1




    See which control is used to output the XML content. That control has a ForeColor property. If the text is instead drawn on a control surface (this is something that is relatively common when building a marquee-like control or using a standard control class (TextBox, Label) as a marquee), the Paint() event of that control should have created a Brush object with a specific Color.
    – Jimi
    Nov 12 at 11:40











  • Updated question, thank you both for the help so far!
    – Scott McCubbin
    Nov 12 at 13:06











  • Move that SetStyle() call out of the Paint() event ASAP. That one goes in the Form's (or any other class) Constructor (Sub New()).
    – Jimi
    Nov 12 at 14:29











  • Thanks for all the help, this is now working
    – Scott McCubbin
    Nov 12 at 15:07













0












0








0







i'm trying to change the font colour of the text on a desktop ticker.



This is the code i currently have:



Private Sub loadthenews()
str = ""
myArray.Clear()
fo = New Font("CALIBRI", 18, FontStyle.Bold, GraphicsUnit.Point)
Dim readXML As New XmlTextReader(Directory.GetCurrentDirectory & "news.xml")


How can i change the colour to something non standard i.e. a HEX or RGB colour.



Thank you



Edit....



I'm looking here:



Private Sub Form1_Paint(ByVal sender As Object, ByVal e As 
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
SetStyle(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.OptimizedDoubleBuffer Or _
ControlStyles.UserPaint, True)
e.Graphics.Clear(Me.BackColor)
e.Graphics.DrawString(str, fo, Brushes.Black, widthX, heightY + 5)


However i need to change the brushes colour from Black to a Hex or RGB color.
Any ideas?



Thanks in advance










share|improve this question















i'm trying to change the font colour of the text on a desktop ticker.



This is the code i currently have:



Private Sub loadthenews()
str = ""
myArray.Clear()
fo = New Font("CALIBRI", 18, FontStyle.Bold, GraphicsUnit.Point)
Dim readXML As New XmlTextReader(Directory.GetCurrentDirectory & "news.xml")


How can i change the colour to something non standard i.e. a HEX or RGB colour.



Thank you



Edit....



I'm looking here:



Private Sub Form1_Paint(ByVal sender As Object, ByVal e As 
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
SetStyle(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.OptimizedDoubleBuffer Or _
ControlStyles.UserPaint, True)
e.Graphics.Clear(Me.BackColor)
e.Graphics.DrawString(str, fo, Brushes.Black, widthX, heightY + 5)


However i need to change the brushes colour from Black to a Hex or RGB color.
Any ideas?



Thanks in advance







vb.net fonts colors






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 13:08

























asked Nov 12 at 10:30









Scott McCubbin

11




11







  • 1




    Font objects don't have a colour. The colour the text appears in is specified elsewhere, e.g. the ForeColor of a control or via a Brush when calling Graphics.DrawString. You need to find where that colour is set in your specific case and set it there.
    – jmcilhinney
    Nov 12 at 10:56






  • 1




    See which control is used to output the XML content. That control has a ForeColor property. If the text is instead drawn on a control surface (this is something that is relatively common when building a marquee-like control or using a standard control class (TextBox, Label) as a marquee), the Paint() event of that control should have created a Brush object with a specific Color.
    – Jimi
    Nov 12 at 11:40











  • Updated question, thank you both for the help so far!
    – Scott McCubbin
    Nov 12 at 13:06











  • Move that SetStyle() call out of the Paint() event ASAP. That one goes in the Form's (or any other class) Constructor (Sub New()).
    – Jimi
    Nov 12 at 14:29











  • Thanks for all the help, this is now working
    – Scott McCubbin
    Nov 12 at 15:07












  • 1




    Font objects don't have a colour. The colour the text appears in is specified elsewhere, e.g. the ForeColor of a control or via a Brush when calling Graphics.DrawString. You need to find where that colour is set in your specific case and set it there.
    – jmcilhinney
    Nov 12 at 10:56






  • 1




    See which control is used to output the XML content. That control has a ForeColor property. If the text is instead drawn on a control surface (this is something that is relatively common when building a marquee-like control or using a standard control class (TextBox, Label) as a marquee), the Paint() event of that control should have created a Brush object with a specific Color.
    – Jimi
    Nov 12 at 11:40











  • Updated question, thank you both for the help so far!
    – Scott McCubbin
    Nov 12 at 13:06











  • Move that SetStyle() call out of the Paint() event ASAP. That one goes in the Form's (or any other class) Constructor (Sub New()).
    – Jimi
    Nov 12 at 14:29











  • Thanks for all the help, this is now working
    – Scott McCubbin
    Nov 12 at 15:07







1




1




Font objects don't have a colour. The colour the text appears in is specified elsewhere, e.g. the ForeColor of a control or via a Brush when calling Graphics.DrawString. You need to find where that colour is set in your specific case and set it there.
– jmcilhinney
Nov 12 at 10:56




Font objects don't have a colour. The colour the text appears in is specified elsewhere, e.g. the ForeColor of a control or via a Brush when calling Graphics.DrawString. You need to find where that colour is set in your specific case and set it there.
– jmcilhinney
Nov 12 at 10:56




1




1




See which control is used to output the XML content. That control has a ForeColor property. If the text is instead drawn on a control surface (this is something that is relatively common when building a marquee-like control or using a standard control class (TextBox, Label) as a marquee), the Paint() event of that control should have created a Brush object with a specific Color.
– Jimi
Nov 12 at 11:40





See which control is used to output the XML content. That control has a ForeColor property. If the text is instead drawn on a control surface (this is something that is relatively common when building a marquee-like control or using a standard control class (TextBox, Label) as a marquee), the Paint() event of that control should have created a Brush object with a specific Color.
– Jimi
Nov 12 at 11:40













Updated question, thank you both for the help so far!
– Scott McCubbin
Nov 12 at 13:06





Updated question, thank you both for the help so far!
– Scott McCubbin
Nov 12 at 13:06













Move that SetStyle() call out of the Paint() event ASAP. That one goes in the Form's (or any other class) Constructor (Sub New()).
– Jimi
Nov 12 at 14:29





Move that SetStyle() call out of the Paint() event ASAP. That one goes in the Form's (or any other class) Constructor (Sub New()).
– Jimi
Nov 12 at 14:29













Thanks for all the help, this is now working
– Scott McCubbin
Nov 12 at 15:07




Thanks for all the help, this is now working
– Scott McCubbin
Nov 12 at 15:07












1 Answer
1






active

oldest

votes


















0














You need to create a new brush:



Dim brush As Brush = New SolidBrush(Color.FromArgb(100,100,100))


Then you can use it instead of the black brush:



e.Graphics.DrawString(str, fo, brush, widthX, heightY + 5)





share|improve this answer




















    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%2f53260258%2fchanging-font-colour-vb-net%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









    0














    You need to create a new brush:



    Dim brush As Brush = New SolidBrush(Color.FromArgb(100,100,100))


    Then you can use it instead of the black brush:



    e.Graphics.DrawString(str, fo, brush, widthX, heightY + 5)





    share|improve this answer

























      0














      You need to create a new brush:



      Dim brush As Brush = New SolidBrush(Color.FromArgb(100,100,100))


      Then you can use it instead of the black brush:



      e.Graphics.DrawString(str, fo, brush, widthX, heightY + 5)





      share|improve this answer























        0












        0








        0






        You need to create a new brush:



        Dim brush As Brush = New SolidBrush(Color.FromArgb(100,100,100))


        Then you can use it instead of the black brush:



        e.Graphics.DrawString(str, fo, brush, widthX, heightY + 5)





        share|improve this answer












        You need to create a new brush:



        Dim brush As Brush = New SolidBrush(Color.FromArgb(100,100,100))


        Then you can use it instead of the black brush:



        e.Graphics.DrawString(str, fo, brush, widthX, heightY + 5)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 14:24









        Meta-Knight

        15.4k4050




        15.4k4050



























            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%2f53260258%2fchanging-font-colour-vb-net%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

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            政党

            天津地下鉄3号線