473,889 Members | 1,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can g.DrawString draw text on top of a label control? any control?

Hello,

I need to draw some text on a form. No problem
....
e.Graphics.Draw String(drawStri ng, drawFont, drawBrush, x, y, drawFormat)

My problem is that I want to draw the text on top of some label controls.
Is there a way to do this using the Graphics DrawString method? Is there a
way to do this using another method?

Thanks
Nov 21 '05 #1
3 2504
I found the answer to this question, and previous questions from yesterday.

First, I want to extend my thanks to Qwert who gave me the answer to my
question about creating transparent labels by creating a user control. Many
thanks Qwert. Your solution worked perfectly. Since I don't have any real
experience to speak of with GDI+, there is no way I would know of the correct
syntax for something like this like:

<Bindable(True) , Category("Appea rance"), _
DesignerSeriali zationVisibilit y(DesignerSeria lizatinoVisibil ity, Visible), _
Browsable(True) >

Well, I created my transparent label and then created a User Control form to
put it on. Then I planted all that on my main form. Works Great!
"Rich" wrote:
Hello,

I need to draw some text on a form. No problem
...
e.Graphics.Draw String(drawStri ng, drawFont, drawBrush, x, y, drawFormat)

My problem is that I want to draw the text on top of some label controls.
Is there a way to do this using the Graphics DrawString method? Is there a
way to do this using another method?

Thanks

Nov 21 '05 #2
Dim g as graphics = anyform.createg raphics
or
Dim g as graphics = anycontrol.crea tegraphics
Nov 21 '05 #3
sorry just read the next message.
You don't need the <attributes> bit.

Incidentally, you don't actually create a transparent usercontrol. What is
actually happening is that Windows generates a background colour equal to
the form your control is on. Try painting the form with a hatch or a
gradient fill and sees what happens!
Nov 21 '05 #4

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

Similar topics

0
1336
by: Marc Ouellette | last post by:
Hi All. In the code below it will output the text string that is using the text from txtTextToDraw.Text using the font properties of the lblFont. Then problem is that not matter the font size in the label. It will also DrawString Bigger. If I change the font type, size of the label the DrawString output will change but it is always bigger the the font displayed on the label. I have no idea why this is happening. Any Idea anyone? ...
1
9371
by: John | last post by:
I'm trying to use the DrawText() method to draw some very long string text on the Panel with AutoScroll enabled. However, for some unknown reasons, I could not trigger the ScrollBar to show up. Here is the simplicied section of drawing code: private void panel_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { panel.AutoScroll = true;
0
539
by: melanieab | last post by:
Hi again, I'm trying to draw a digital clock in the corner of a picturebox whenever a particular tabpage is in focus. I either need to be able to make the clock keep real time (I can get it to draw when the page loads, but it won't "tick") or I need to be able to draw a transparent label background (I can get the clock working on a solid color label). Thanks again for everyone's help! Melanie
1
2002
by: Joao | last post by:
Hi, I'm trully excited to use VB.NET's PrintDocument to make my printouts. On them I draw strings, images and lines. All perfect, if I invoke the Print or the PrintPreview one time per run. At second time I onvoke print or preview, the DrawLine or DrawImage go well, but the first DrawString the program tries to execute pops an exception: ************** Exception Text ************** System.ArgumentException: Invalid parameter used.
2
2980
by: Martin | last post by:
Hello All, I've created a WinForm control and everything is OK except the look of the font on my control. protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
3
2873
by: Allen | last post by:
I've got a control that you can resize the contents of one of the text fields inside it. When the contents are resized to smaller than the text, I remove some of the end of the text and substitute ... at the end. This is where the wierdness sets in. Any time I remove or change some letters at the END of the text and draw, the spacing throughout the text string changes!!! So when I resize it in and out, the whole line looks like its...
3
2535
by: =?Utf-8?B?SlIx?= | last post by:
I would like to add text to an image. I have tried to use DrawString and it works on some images but on others it is very very small. I am pretty sure it has something to do with the size of the image but I have had varying results on multiple images. Is there anyway to make the text a fixed size on the image. Similar to putting a date on a photograph.
2
2547
by: ChrisNightingale | last post by:
Hi everybody, I have an odd issue which I'm not sure how to resolve. I'm basically implementing a print mechanism which takes a series of controls and reproduces them on a print document. So what I'm trying to do is print out a label so what I basically did is use Graphics.DrawString passing in the text of the label, the font of the label and the rectangle which represents the label (because it's set to autosize this should be the right...
3
5338
by: Larry | last post by:
I'm sure I've missed the obvious, but when I define a custom color, my DrawString call from my Paint event doesn't seem to draw anything at all. void btnNav_Paint(object sender, PaintEventArgs e) { SolidBrush brush1 = new SolidBrush(Color.Blue); SolidBrush brush2 = new SolidBrush(Color.FromArgb(0x0000FF)); StringFormat format = (StringFormat)StringFormat.GenericTypographic.Clone();
0
9810
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11198
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10791
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10889
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10442
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7993
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5829
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6029
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4251
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.