473,516 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Brush and control.forecolor Question

I have the following string:

e.Graphics.DrawString(Label5.Text, lblP1B1.Font, Brushes.White, -y, 0)

I want to use the property label.forecolor for my text color. How do I get
whats in label.forecolor into the Brushes.Color parameter?

Thank you,
John
Nov 20 '05 #1
3 2263
John,

Create a new brush with something like:

<code (VB.NET) >
Dim aBrush As New SolidBrush(Me.Label1.ForeColor)
graphics.DrawString("This is a test", Me.Label1.Font, aBrush, 10, 10)
</code>

-Sam Matzen

"jcrouse" <me> wrote in message
news:OU**************@TK2MSFTNGP12.phx.gbl...
I have the following string:

e.Graphics.DrawString(Label5.Text, lblP1B1.Font, Brushes.White, -y, 0)

I want to use the property label.forecolor for my text color. How do I get
whats in label.forecolor into the Brushes.Color parameter?

Thank you,
John

Nov 20 '05 #2
John,
As Samuel suggested, create a new brush, I would be certain to Dispose of
the brush when you were done.

Something like:
Dim aBrush As New SolidBrush(Me.Label1.ForeColor)
graphics.DrawString("This is a test", Me.Label1.Font, aBrush, 10, 10)
aBrush.Dispose()

Rather then create & dispose of the brush in the paint event itself, I would
consider disposing of the old one & creating a new one in the ForeColor
property Get.

Something like:

Private m_brush As SolidBrush

Public Overrides Property ForColor As Color
Get
Return MyBase.Color
End Get
Set(ByVal value As Color)
m_brush.Dispose()
m_brush = New SolidBrush(value)
MyBase.ForeColor = value
End Set
End Property

Hope this helps
Jay
"jcrouse" <me> wrote in message
news:OU**************@TK2MSFTNGP12.phx.gbl...
I have the following string:

e.Graphics.DrawString(Label5.Text, lblP1B1.Font, Brushes.White, -y, 0)

I want to use the property label.forecolor for my text color. How do I get
whats in label.forecolor into the Brushes.Color parameter?

Thank you,
John

Nov 20 '05 #3
Resolved!

Thank you,
John

"jcrouse" <me> wrote in message
news:OU**************@TK2MSFTNGP12.phx.gbl...
I have the following string:

e.Graphics.DrawString(Label5.Text, lblP1B1.Font, Brushes.White, -y, 0)

I want to use the property label.forecolor for my text color. How do I get
whats in label.forecolor into the Brushes.Color parameter?

Thank you,
John

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3115
by: Christopher Young | last post by:
I have several user controls on a page and I am trying to get information out of them. The postback is being caused on the aspx page and not in the user control. I have tried using a property but I keep getting a message that the object is not referenced. What I am trying to do is be information from text boxes and insert them into a new...
1
1144
by: Douglas Gage | last post by:
I have two columns Question Answers Q1 Q2 Q3 Q4 Submit
1
339
by: Frank Bishop | last post by:
I have a user control that will open and close the calendar control when the user clicks on an anchor tag. Instead of having the user remember to close the calendar after they make a day selection, I would like the calendar to close itself after the day selection. I'm using the day selected to feed a text box (code not shown here). Here is my...
11
2234
by: PAul Maskens | last post by:
The form designer adds unnecessary code to the section when using a subclassed control. I've reproduced this in VS.NET 2002 and VS.NET 2003 so it's pretty fundamental. Outline steps: Create a VB project. Create a subclass of a UI control, I used TextBox. Add no code to the subclass. Public Class Component1
1
10432
by: Nam | last post by:
I have a DropDownList control in a TemplateField inside my GridView How do I access this control’s SelectedIndexChanged event in codeBehind page? I don’t see the ID “DropDownList1” of this control in the list of objects in odeBehind page. GridView1 and DropDownList1 are bound to TWO DIFFERENT tables (DataSources). The last column...
2
4121
by: Paul | last post by:
I am using the standard Calendar control in ASP.Net 2.0 and VB.Net and VS2005. Here is the code: <asp:calendar id="cldr_contract_date" runat="server" backcolor="#ffffff" width="250px" height="200px" font-size="12px" font-names="Arial" borderwidth="2px" bordercolor="#000000" nextprevformat="shortmonth" daynameformat="firsttwoletters"...
1
2814
by: bushi | last post by:
hi! i'm getting the data form the database by using datalist control,and have assigned the value to hidden field control in aspx file,now i want to get the value of hidden field in my aspx.cs file,for some manipulations.how i can get it? code is given below: <asp:DataList ID="DataList1" runat="server" DataKeyField="urls"...
2
1530
by: Johnny J. | last post by:
I've got an inherited control where I want the user to be able to specify a color property. Using that color, I'm drawing a line private m_UserDefinedColor as Color ..... Dim g as Graphics=this.CreateGraphics Dim myPen as Pen = new Pen(m_UserDefinedColor) g.DrawLine(myPen, X1, Y, X2 - 1, Y)
2
7646
by: Ken Fine | last post by:
I want to add the security question and answer security feature to the ChangePassword control. I am aware that this functionality is built into the PasswordRecovery tool. I have implemented the PasswordRecovery with a Password reset required; a temporary password is sent to the account on file. I want an extra layer of security to accommodate...
0
7276
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7548
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5714
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
1624
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
825
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.