How do I get the first visible item in RadListView?

1 Answer 31 Views
ListView
Yoshinari
Top achievements
Rank 1
Yoshinari asked on 08 May 2025, 12:41 AM

Hi!

How do I get the first visible item in RadListView?
And how do I set it up?
Like the TopItem property of a WinForms ListView.

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 09 May 2025, 08:34 AM

Hello, Yoshinari,

In RadListView, at this moment there is no direct TopItem property like in the standard ListView. However, you can determine the top item by using the GetItemAt method and pass point at the top of visible area:

//Get top item
ListViewDataItem topItem = (this.radListView1.ListViewElement.ViewElement as SimpleListViewElement).GetItemAt(new Point(10,10));
if (topItem != null)
{
   MessageBox.Show($"Top item: {topItem.Text}");
}

If you need to set a top item and make it visible in the view area you can make use of the EnsureItemVisible method and pass the desired item. This ensures that the desired item is scrolled into view and optionally placed at the top.

//Set Top item
ListViewDataItem item = this.radListView1.Items[0];
this.radListView1.ListViewElement.EnsureItemVisible(item);

Can you please give these suggestions a try and let me know how they work for you.

I hope this helps. If you have other questions, please let me know.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Yoshinari
Top achievements
Rank 1
commented on 16 May 2025, 12:35 AM

Hi Nadia,

Thank you, very helpful.
I want to use the “DetailView” style, so I did the following.

ListViewDataItem topItem = (this.radListView1.ListViewElement.ViewElement as DetailListViewElement).GetItemAt(new Point(10, (int)(10 + this.radListView1.HeaderHeight)));

Thank you for your help, I will try to get this to work.

Sincerely,
Yoshinari

Nadya | Tech Support Engineer
Telerik team
commented on 16 May 2025, 09:00 AM

Hello, Yoshinari,

I am glad that my solution was helpful. Yes, you can customize the solution according to your needs. Feel free to make adjustments when using different views in RadListView.

In case you have any other questions, do not hesitate to contact me.

Tags
ListView
Asked by
Yoshinari
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or