Reputation: 565
I want to get the position of a ListView item / subitem. What I mean by that is that I want to get a Left and a Top for this subitem. This is the position I mean:
.
I tried this:
int item_x = list.Items[1].SubItems[2].Bounds.X;
int item_y = list.Items[1].SubItems[2].Bounds.Y;
But it doesn't seem to give the correct position I want.
Upvotes: 0
Views: 1377
Reputation: 565
Ok, it seems that what I wrote before was kind of correct. It just needed correcting with some adding and subtracting, then it showed like this: http://spunit.cf/x/scrn370.png.
Thanks for making me realize this =).
Here's the code for it:
int item_l = list.Items[1].SubItems[2].Bounds.Left + 3;
int item_t = list.Items[1].SubItems[2].Bounds.Top + 29;
int item_w = list.Items[1].SubItems[2].Bounds.Width - 1;
int item_h = list.Items[1].SubItems[2].Bounds.Height - 1;
ListView listt = new ListView();
Controls.Add(listt);
listt.BringToFront();
listt.Bounds = new Rectangle(new Point(item_l, item_t), new Size(item_w, item_h));
Upvotes: 1