Click here to Skip to main content
15,886,362 members
Home / Discussions / C#
   

C#

 
Questionopen an Excel file using c# Pin
ramyanaidu29-Nov-07 23:37
ramyanaidu29-Nov-07 23:37 
AnswerRe: open an Excel file using c# Pin
NewToAspDotNet30-Nov-07 0:35
NewToAspDotNet30-Nov-07 0:35 
Question"out of memory" exception and resource management Pin
metalion29-Nov-07 23:14
metalion29-Nov-07 23:14 
AnswerRe: "out of memory" exception and resource management Pin
Christian Graus29-Nov-07 23:17
protectorChristian Graus29-Nov-07 23:17 
GeneralRe: "out of memory" exception and resource management Pin
metalion29-Nov-07 23:23
metalion29-Nov-07 23:23 
AnswerRe: "out of memory" exception and resource management Pin
Luc Pattyn30-Nov-07 0:45
sitebuilderLuc Pattyn30-Nov-07 0:45 
GeneralRe: "out of memory" exception and resource management Pin
metalion30-Nov-07 1:25
metalion30-Nov-07 1:25 
QuestionIDeviceContext OR How to MeasureText out of the Paint Event Pin
C-Scharbe29-Nov-07 23:04
C-Scharbe29-Nov-07 23:04 
Hello,

I'd like to Resize a control that contains any text.
If I use TextRenderer.MeasureText there is always a Padding, also if I use the Flag NoPadding:
Size size = TextRenderer.MeasureText("dddd", this.Font, new Size(Int32.MaxValue, Int32.MaxValue), (TextFormatFlags.NoPadding));

I found out that i need to set a IDeviceContext like that:
private void MyControl_Paint(object sender, PaintEventArgs e)<br />
{<br />
      Size size = TextRenderer.MeasureText(e.Graphics, "dddd", this.Font, new Size(Int32.MaxValue, Int32.MaxValue), (TextFormatFlags.NoPadding));<br />
}


My Problem is:
I dont want to Resize the Control in the Paint-Event, so I guess I need to get somehow the current IDeviceContext, but how?
Or do I use the TextRenderer.MeasureText method in a wrong way?


Thank You for Your Answers!
AnswerRe: IDeviceContext OR How to MeasureText out of the Paint Event Pin
C-Scharbe30-Nov-07 1:04
C-Scharbe30-Nov-07 1:04 
GeneralRe: IDeviceContext OR How to MeasureText out of the Paint Event Pin
mav.northwind30-Nov-07 21:05
mav.northwind30-Nov-07 21:05 
QuestionImpersonation in C# Pin
dhanashree_129-Nov-07 23:02
dhanashree_129-Nov-07 23:02 
QuestionReplacing ReportViewer with Internet Explorer Pin
Ramith Sivanarain29-Nov-07 23:02
Ramith Sivanarain29-Nov-07 23:02 
QuestionExternal device Pin
Lol2129-Nov-07 23:01
Lol2129-Nov-07 23:01 
AnswerRe: External device Pin
MickCurley29-Nov-07 23:10
MickCurley29-Nov-07 23:10 
AnswerRe: External device Pin
ChandraRam30-Nov-07 1:59
ChandraRam30-Nov-07 1:59 
QuestionProblem in opening an excel file using C# Pin
ramyanaidu29-Nov-07 22:54
ramyanaidu29-Nov-07 22:54 
AnswerRe: Problem in opening an excel file using C# Pin
NewToAspDotNet29-Nov-07 23:53
NewToAspDotNet29-Nov-07 23:53 
Question.net 2005 clickonce error Pin
arkiboys29-Nov-07 22:47
arkiboys29-Nov-07 22:47 
GeneralRe: .net 2005 clickonce error Pin
Sam Xavier17-Jan-08 23:56
Sam Xavier17-Jan-08 23:56 
Questioncounting Attributes in xml file of one childnode [modified] Pin
Ravi Shankar4329-Nov-07 22:37
Ravi Shankar4329-Nov-07 22:37 
AnswerRe: counting Attributes in xml file of one childnode Pin
Christian Graus29-Nov-07 22:48
protectorChristian Graus29-Nov-07 22:48 
GeneralRe: counting Attributes in xml file of one childnode Pin
Ravi Shankar4329-Nov-07 22:53
Ravi Shankar4329-Nov-07 22:53 
AnswerRe: counting Attributes in xml file of one childnode Pin
Christian Graus29-Nov-07 23:09
protectorChristian Graus29-Nov-07 23:09 
QuestionHow to send MDNS Query over UDP to get Domain Name Pointer (PTR)? Pin
Jakob Farian Krarup29-Nov-07 22:29
Jakob Farian Krarup29-Nov-07 22:29 
AnswerMessage Closed Pin
18-Oct-12 3:39
professionalLeo Chapiro18-Oct-12 3:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.