473,494 Members | 2,223 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Drawing.StringFormat in a paint method

I have a DataGridLabelColumn I've made by overriding a DataGridColumnStyle
object. (based on an MSDN article by Chris Sano).
In the Paint method, I use a StringFormat object, and pass that to a
Graphics.DrawString method. I am finding that the strings I am passing to
the drawstring method are being manipulated: text suffixed with a "?" or
")" are being painted with the "?" as a PRE-fix, and my ")" is being moved
to the front of the string and being painted (for lack of a better word) as
"(". If I remove my StringFormat from the DrawString call, then this
behaviour goes away and the string is painted as is. I looked on MSDN for
some clarification but it doesn't detail how strings are interpreted, nor
how to prevent this behaviour.

Any guidance would be appreciated.
The following is the code snippet.

StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Far;
sf.LineAlignment = StringAlignment.Center;
sf.FormatFlags = StringFormatFlags.DirectionRightToLeft |
StringFormatFlags.FitBlackBox;

g.FillRectangle( backBrush, bounds );

g.DrawString(
this.GetColumnValueAtRow( source, rowNum ).ToString(),
this.DataGridTableStyle.DataGrid.Font,
foreBrush,
bounds, sf ); //<-- if sf is ommitted here, then the my weird string
formatting goes away
Nov 17 '05 #1
0 2197

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

Similar topics

7
3519
by: Jeroen Ceuppens | last post by:
Hi, When I draw a bitmap on a form, the bitmapdrawing disappears when I move the form, how is it possible to lock the drawing so it stays visible when you move or do somethings else.... Thx...
4
12298
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...
5
4313
by: BluDog | last post by:
Hi I am trying to draw text in a panel. I want the width of the panel to be fixed but the height to be determined by the number of lines the text needs to cover in the panel. I also want to be...
0
1107
by: Stan Sainte-Rose | last post by:
Hi, I have a problem with alignment with a datagrid. When I use the SF variable with g.DrawString function, my first Decimal Column is merged with the previous so my last column is blank. If I...
4
2220
by: Urs Vogel | last post by:
Hi During the paint event, I can DrawText from left to right, or from top to bottom (angled by 90°) by setting the Drawing.StringFormat.FormatFlags, but how can I drawText from right to left...
5
1214
by: brix_zx2 | last post by:
vb.net 2k3: I have this code that doesn't work unless I take out the g.DrawString statements. If anyone can look over the code and tell me why I'd appreciate it. Dim g As Graphics Dim...
9
3158
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...
11
9256
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,...
4
26925
by: RobinS | last post by:
I am drawing a rectangle on a picture that has already been drawn on the graphics area (a user control). It works something like this: //in the MouseDown event m_isDragging = true; m_oldX =...
0
7157
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
7195
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...
0
7367
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
5453
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
4889
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
3088
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.