Get index number of selected thumbnail
-
- Posts: 38
- Joined: Thu Sep 22, 2016 4:56 am
Get index number of selected thumbnail
Hi,
Does anybody here knows how to get the current index of a selected thumbnail item?
Thank you..
Does anybody here knows how to get the current index of a selected thumbnail item?
Thank you..
Re: Get index number of selected thumbnail
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
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
-
- Posts: 38
- Joined: Thu Sep 22, 2016 4:56 am
Re: Get index number of selected thumbnail
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?
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?
Re: Get index number of selected thumbnail
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.
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.
-
- Posts: 38
- Joined: Thu Sep 22, 2016 4:56 am
Re: Get index number of selected thumbnail
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.
Who is online
Users browsing this forum: No registered users and 2 guests