Hi eveyone,
I can add a String or a ListBoxItem into Listbox.
When item of Listbox is a ListBoxItem, I can get rectangle by calling "ListBoxItem.PointToScreen(point)".
But if item of Listbox is a String, how can I get its rectangle?
Any help would be appreciated!
Kiet.
Loading
Mike GoldPosted Sep 2, 2010, 11:13 PM
private void button1_Click(object sender, EventArgs e)
{
string val = listBox1.Items[0].ToString();
var g = this.CreateGraphics();
SizeF itemRectangleSize = g.MeasureString(val, listBox1.Font);
var rectangle = new RectangleF(new PointF(0, 0), itemRectangleSize);
}