473,473 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Drawing text in C#

4 New Member
Hi , Can someone one help me please.I'm begginer in C#, and I try to learn it , but I need help.
I have in my form 2 spliterPamels, in one of them I want to display text when form is load. The problem is that I want to create the text dinamicaly but it doesn't work . Here is the code I try to test
protected override void OnPaint(PaintEventArgs e)
{
paint_Text(e.Graphics);
base.OnPaint (e);
}

....
private void paint_Text(Graphics gr)
{

int beginYtop = mainsplitContainer.Panel2.Margin.Top;
int beginXtop = mainsplitContainer.Panel2.Margin.Left;
int beginYbottom = mainsplitContainer.Panel2.Margin.Bottom;
int beginXbottom = mainsplitContainer.Panel2.Margin.Right;
RectangleF rect = new RectangleF(beginYtop + 10, beginXtop + 10, beginYbottom - 10,
beginXbottom - 10);

Font objFont = new System.Drawing.Font("Lucida Console", 12, FontStyle.Italic);
StringFormat sf = (StringFormat)StringFormat.GenericTypographic.Clon e();
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
sf.Trimming = StringTrimming.EllipsisWord;
gr.DrawString("ERRR", objFont, System.Drawing.Brushes.Azure,
rect, sf);
objFont.Dispose();
}
...
private void Form1_Load(object sender, EventArgs e)
{
Graphics g = Graphics.FromHwnd(this.Handle);
paint_Text(g);
}

Can you pese help me,
Thank you
Jul 28 '07 #1
0 1152

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Christina Androne | last post by:
Hi I want to allow the user to drow some locators on an image and connect the locators with lines. So I tried to put the following code in the onmousedown enevt of the picture: Graphics...
4
by: Stuart Norris | last post by:
Dear Readers, I am attempting to draw box around some text using unicode on multiline label. The label is forty characters wide and 12 lines deep. I have been trying to draw a box around text...
10
by: tshad | last post by:
I have a problem setting the background color of textbox on the fly. I tried using: applicantID.backcolor = "F6F6F6" and applicantID.backcolor = "#F6F6F6"
13
by: Metallicraft | last post by:
I have a vb6 application. On the main form is a picture box with one or two images and several pieces of text displayed in it. These are created on the fly using gdi32 routines that are all in a...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
0
by: Hasim AH | last post by:
Hi .. Just getting interested to learn C# and needs help. I want to write C# application so that the program will execute and draw graphics when the user select the drawing menu from the main...
11
by: dongarbage | last post by:
Hi there, I'm very much a C# novice. How do you do freehand drawing on a panel with a mouse in c#? Thanks, Don
11
by: cty0000 | last post by:
I have some quiestion... I want to draw line,point,rectangles and etc... on the from So I code like this.. public update() { g = this.CreateGraphics(); g.FillRectangle(Brushes.White, x1,...
0
by: emilnordiclake | last post by:
(C#, Microsoft .NET Framework 3.5) Hello! I'm in the process of creating a custom text control and I want to add functionality for superscripts and subscripts. I'm using TextRenderer for...
2
by: ThatsIT.net.au | last post by:
I have this code that writes a pie chart in a asp.net page, but I want to use it in a server control. When I try I get a error on the last line "Response.OutputStream" Obviously there is no...
0
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...
0
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,...
0
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...
1
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...
0
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...
0
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 project—planning, coding, testing,...
1
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...
0
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...
1
muto222
php
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.