float startPos = e.Graphics.MeasureString(toMeasure, f);
e.Graphics.DrawString(keyword, f, sb, new PointF(e.Bounds.X + (int)startPos, e.Bounds.Y));
This is f
:
using (Font f = new Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular))
And this is toMeasure
:
string toMeasure = data[e.Index].Substring(0, keywords - 1);
The error is on the line:
float startPos = e.Graphics.MeasureString(toMeasure, f);
The error is:
Cannot implicitly convert type 'System.Drawing.SizeF' to 'float'
How can I fix it? Since the second line should get float but the first line can't convert from SizeF
to float
.
If you want the Width
of the string
you will have to get the Width
from the SizeF
stucture returned from MeasureString
Example:
float startPos = e.Graphics.MeasureString(toMeasure, f).Width;
Method MeasureString
returns SizeF
object.
SizeF startPos = e.Graphics.MeasureString(toMeasure, f);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With