Get index number of selected thumbnail

Example requests & Code samples for GdPicture Toolkits.
Post Reply
ejbrandino
Posts: 38
Joined: Thu Sep 22, 2016 4:56 am

Get index number of selected thumbnail

Post by ejbrandino » Tue Oct 25, 2016 7:12 am

Hi,

Does anybody here knows how to get the current index of a selected thumbnail item?

Thank you..

David
Posts: 66
Joined: Mon Feb 08, 2016 3:12 pm

Re: Get index number of selected thumbnail

Post by David » Tue Oct 25, 2016 9:59 am

Hi,

Thank you for your question.

As the control offers multi selection, it is required to loop through all the elements to test whether they are selected or not. The GetItemSelectState method is designed to this purpose.

The method is described within the standard documentation:
https://www.gdpicture.com/guides/gdpicture/GdP ... State.html

Regards,

David

ejbrandino
Posts: 38
Joined: Thu Sep 22, 2016 4:56 am

Re: Get index number of selected thumbnail

Post by ejbrandino » Wed Oct 26, 2016 11:46 pm

Hi David,

Thanks for the reply, I tried your approach but still no luck. I have this code below for testing purposes, I placed it on the click event and set the index on my global variable.

private void Thumbnail_Click(object sender, EventArgs e)
{
for (int i = 0; i < Thumbnail.ItemCount - 1; i++)
{
if (Thumbnail.GetItemSelectState(i))
{
Globals.thumbnailIndex = i;
}
}
MessageBox.Show("Index is: " + Globals.thumbnailIndex, "TEST", MessageBoxButtons.OK, MessageBoxIcon.Information);

}

I loaded a pdf document containing 3 pages, but when when I clicked the pages one by one starting from page 1 to 3, the indexes are 0,1,1 respectively. Its supposed to be 0,1,2 right? what am i missing?

Cedric
Posts: 269
Joined: Sun Sep 02, 2012 7:30 pm

Re: Get index number of selected thumbnail

Post by Cedric » Thu Nov 03, 2016 4:10 pm

There is no need to do that if the goal is just to retrieve the clicked thumbnail index, there is a built-in event that does that for you already.
You need to catch the ItemClicked event, it provides two arguments: one is the thumbnail index that has been clicked and the other one is the mouse button that has been used in case you want to do something different whether the right or left mouse button has been used.

ejbrandino
Posts: 38
Joined: Thu Sep 22, 2016 4:56 am

Re: Get index number of selected thumbnail

Post by ejbrandino » Fri Feb 03, 2017 2:55 am

How about getting the indexes of multiple pages selected? I tried David's suggestion but still, it doesn't work out.. I can get the index of a single page selected just like you said how to get it, but I don't know how to get it when selecting MULTIPLE pages.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest