Monday, 9 September 2013

How to split a string of fix width using GDI +?

How to split a string of fix width using GDI +?

I have a big string that has got comma and new line character, i need to
draw this string in a panel of fix width i want to take off each time
string of length of panel width so that i can draw each string from new
line.
foreach (btnObject custItem in this.lstDeniedCustomization)
{
basketItemDescription = basketItemDescription + custItem.BtnName + ", ";
}
the basketitemdescription holds the string that i need to break of equal
width of panel width.
I was trying with this..
System.Drawing.SizeF mySize = g.MeasureString(basketItemDescription,
this.Font); //get the size of the text property
float stringHeight = mySize.Height;
this.Height = mySize.Height;
but it gives me just the width and height of whole string while i need to
draw it in a panel of some fixed width while the height need to fix at run
time.

No comments:

Post a Comment