Click here to Skip to main content
15,887,776 members
Everything / ListView

ListView

ListView

Great Reads

by ThatsAlok
Using Fragments in your mobile application.
by #realJSOP
A WPF ListView that automatically generates columns (that are also sortable) based on decorated entity properties
by John Atten
Examination of a quick way to create more useful expandable groups in the .NET ListView control.
by Technoses
The above code will slow down the browser and the browser can hang when Rows in Grid will be 10000 or above.Please view the below suggestion:CS Codeprotected void grvGroups_RowDataBound(object sender, GridViewRowEventArgs e){ if (e.Row.RowType == DataControlRowType.DataRow) { ...

Latest Articles

by Jovibor
List Control with tooltips, cells editing, colors, sorting, hyperlinks, columns hiding, and a lot more
by #realJSOP
A WPF ListView that automatically generates columns (that are also sortable) based on decorated entity properties
by Thiagarajan Rajendran
How to create a checkbox list using simple HTML and jQuery
by Michael Shpilt
A WPF tutorial on how to create FilteredListView: A ListView custom control with search filter that uses Throttling.

All Articles

Sort by Score

ListView 

21 Nov 2013 by ThatsAlok
Using Fragments in your mobile application.
18 Feb 2021 by #realJSOP
A WPF ListView that automatically generates columns (that are also sortable) based on decorated entity properties
23 May 2012 by VJ Reddy
For the properties of the object set at design to be persisted in the form the DesignerSerializationVisibilityAttribute with the argument DesignerSerializationVisibility.Content is to be used like _Public ReadOnly...
3 Sep 2012 by John Atten
Examination of a quick way to create more useful expandable groups in the .NET ListView control.
27 Jun 2012 by Technoses
The above code will slow down the browser and the browser can hang when Rows in Grid will be 10000 or above.Please view the below suggestion:CS Codeprotected void grvGroups_RowDataBound(object sender, GridViewRowEventArgs e){ if (e.Row.RowType == DataControlRowType.DataRow) { ...
23 Jan 2011 by Manfred Rudolf Bihy
Please try ListView.EnsureVisible(int index). See here: http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.ensurevisible.aspx[^]
14 Jun 2012 by Valery Possoz
Hello,A solution is to use Insert instead of Add.'FIRST DOWNLOADWith lstDownload.Items.Add("Sample", 0) .SubItems.Add(2) .SubItems.Add(3) .SubItems.Add(4) .SubItems.Add(5) .SubItems.Add(6) .SubItems.Add(listDownload.Count - 1)End With'SECOND...
1 Apr 2013 by Sergey Alexandrovich Kryukov
Don't serialize/deserialize controls. Have a data layer, serialize the data and use it to populate the controls, and update. —SA
18 Jul 2016 by Andy Point
Android Alert Dialog Tutorial : Working with Time Picker, Date Picker and List Dialogs In this tutorial we will discuss how to use dialogs and alerts in Android Apps. A Dialog is a small popup shown to the user to get some additional information from the user or ask him to make some decision. Alert
5 Dec 2023 by Richard Deeming
Quote: Unable to cast object of type 'System.Web.UI.WebControls.Label' to type 'System.Web.UI.WebControls.TableCell'. Well there are two places where that error could occur, and they both refer to the same control: ...
23 Apr 2013 by David McNamara
The problem here is that the structure of NMHDR has changed for x64. The idFrom field is now IntPtr:public struct NMHDR { /// hwndFrom public IntPtr hwndFrom; /// idFrom public IntPtr idFrom; /// code public int code; }I...
17 Mar 2024 by Pete O'Hanlon
You cannot tell if an object has been changed using an ObservableCollection. The way to do this is to use INotifyPropertyChanged and raise the PropertyChanged event whenever you change the value in a property.
N 15 Apr 2024 by Graeme_Grant
If you are using data binding, like in this article here: Data binding a ListView[^], then the ListView control becomes a view of the data, not the data container itself. Then you only need to show the properties as columns, as required. This...
10 May 2023 by Jovibor
List Control with tooltips, cells editing, colors, sorting, hyperlinks, columns hiding, and a lot more
4 May 2011 by Wonde Tadesse
Here is a good example how to use ListView and XML together.Displaying ListView and XML[^]I hope this will help you well.
3 May 2013 by Sergey Alexandrovich Kryukov
The name of you method suggests that you are handling the event when the selection is changed (never, never use such names, rename auto-generated names to something semantic; and never ask questions like that; always show how you add a handler to an invocation list of an event instance, "+="...
3 Sep 2013 by Christopher Kenis
Here's a example of the code:public Form1() { InitializeComponent(); //Set the listView Visible property to false listView1.Visible = false; } private void button1_Click(object sender, EventArgs e) { ...
11 Oct 2013 by ASP.NET Community
  The ListView control is a new data presentation control that was added to .Net 3.5 , you may wonder why its added to the framework , and what it
5 Jan 2016 by F-ES Sitecore
' runat="server" />
14 Apr 2024 by Ravi Bhavnani
There's no standard way to do this in Windows Forms. The alternative I use is to manage a ListView's configuration in another object and initialize and populate the ListView appropriately.� See this screenshot as an example:...
N 14 Apr 2024 by Pete O'Hanlon
As an alternative to Ravi's answer, there is a quick and dirty "hack" that you can use, assuming you are using Windows Forms here. When you add an item into a listview, you are adding an instance of a ListViewItem. This class has a Tag property...
28 Nov 2010 by Kirankumar Ballapalli
Hi,You can solve the above function by writing following javascript fucntion.Call the below function in Population, male, and female columns on onkeypress event of text boxes as follows.onkeypress="javascript:return CalculateValue(this);";function CalculateValue(obj){ var...
8 Feb 2011 by Monjurul Habib
Catch it on ListView ItemDataBoundPlesae dont copy and paste, try to understand.example.aspx DataSourceID="SqlDataSource1" ItemPlaceholderID="SqlItemContainer"...
25 May 2011 by Timberbird
What actually is taking so much time? Is it your loop itself (I do believe 30000 iterations last not that long) or are there additional actions slowing the process? You could try to disable event handlers (ItemSelectionChanged and the like, all that may be triggered by selection) or call...
27 Dec 2011 by Espen Harlinn
Have a look at ObjectListView[^]Here is an article A Much Easier to Use ListView[^].If you really want to use the standard listview, have a look at custom painting[^].Best regardsEspen Harlinn
16 Jan 2012 by Sergey Alexandrovich Kryukov
Thank you for compliance and clarification of the question (I up-voted it). It's the best to modify the question itself and leave the notification in a comment. You should also tag the UI library, for your own good. Please see my last comment to the question. There are some commercial...
29 May 2012 by OriginalGriff
How the heck do you expect that to work?"any computer related word" and "nanotechnology" does not give you a suitable subject for a PhD thesis.What if we did give you what you ask: "Cloud-storage and nanotechnology", or "binary and nanotechnology". What happens in three years time when you...
24 Apr 2013 by GRF75
From different sources from the web, this finally worked:In XAML: In...
3 May 2013 by Sergey Alexandrovich Kryukov
Wajrak wrote:But you make me wonder with one thing you wrote and if you don't mind (and I think you don't, because last time you spent a lot of your time after answering my question explaining some other things to me), it was: "never, never use such names, rename auto-generated names to...
13 Jun 2013 by Deepali Dhingra
This tip explains how to create a to do or Shopping List app with listview, sqlite, dialog and customadapter
2 May 2014 by Shai Vashdi
WPF has a special structure for that called: LogicalTreeHelper.http://msdn.microsoft.com/en-us/library/system.windows.logicaltreehelper.aspx[^]
8 May 2014 by DamithSL
.mylink a{ text-decoration: none; font-size: 12px;}.mylink a:hover{ text-decoration: none; font-size: 11px; font-weight: bold;}
9 Jun 2014 by Nayan Rudani
You may try with :for (int i = 0; i
17 Feb 2015 by Jochen Arndt
There is no function to move items inside the list. So the move process has to splitted into delete and insert operations. For multiple items this can be done in two ways: Deleting all selected items first before inserting them at the new position or perform the delete / insert for each...
5 Jan 2016 by ridoy
Use listView.Items.Remove(listView.SelectedItem) and you can call it from your delete button's click event.Or run a foreach loop and see if the item is selected, then remove it.foreach(var v in listView.SelectedItems){ listView.Items.Remove(v)}
9 Apr 2016 by Mycroft Holmes
You need a little more than just settings, take a look at this entry[^].
29 Apr 2016 by Matt T Heffron
Since ListViewItemCollection and SelectedListViewItemCollection both implement IEnumerable, what I'd suggest is to declare myItems as IEnumerable:IEnumerable myItems;if (SelectAll){ myItems = listView1.Items; }else{ myItems = listView1.SelectedItems; } foreach...
12 Dec 2017 by raddevus
Apparently ListItems will not stretch to fill a space, but the Header item will. To fix the problem you have to add the following to your ListView ...
10 Apr 2018 by #realJSOP
You could try this (no guarantees): stView1.SelectedIndexChanged-=listView1_SelectedIndexChanged; listView1.SuspendLayout(); try { // selection loop } finally { listView1.SelectedIndexChanged+=new EventHandler(listView1_SelectedIndexChanged); listView1.ResumeLayout(); }
13 Oct 2022 by Dave Kreskowiak
You don't. You cannot touch a control from any other thread other than the UI (startup) thread. You're using the ListView control as a container for data instead of its intended purpose of displaying and editing data. You should be holding all...
23 Jun 2010 by Vineeth P Joseph
Hi, I think you are defining new Control template for the ListViewItem.Do one more think and try. Now you are changing the template on the IsSelected trigger right.You have to do the sane think on the following trigger ...
16 Jul 2010 by michaelschmitt
Hi,in "SetColumnHeaders(..)" you create the columns for your listviews.That only works for the first listview, as you set the ColumnsSetclass variable to true while filling the first one. Then, whenfilling the second one, this variable is already set to true and youdont do it again...
20 Jul 2010 by «_Superman_»
This will probably help you - A Multiline Header Control Inside a CListCtrl[^]
6 Oct 2010 by Fredrik Bornander
The following example shows how you can set values for a list view by specifying row and column and a value to set.The example will add a new line if required but will not add more columns than defined on the list view:private void UpdateListViewValue(ListView listView, int row, int...
9 Dec 2010 by Danny Hulmston
An application which I'm currently coding compares two imported xml documents and shows the differences between them. I want to be able to scroll down with one scroll bar and have the second scroll automatically duplicate the movement made by the first scroll bar. I've looked on Google for some...
20 Dec 2010 by fjdiewornncalwe
In every site they mention about DrawItem() and DrawColumnHeader() because that is your answer. You have to override the default event behavior for those one or both of those handlers for your ListView control. In that code you can grab which column the mouse is over and update the header as...
20 Dec 2010 by OriginalGriff
The reason they talked about using DrawItem and/or DrawColumnHeader is because that is the way to do it. ColumnHeader is not derived from control, so it does not have a colour directly.Go back, look at the replies you got, and try it!
23 Jan 2011 by Henry Minute
ListView has the TopItem property that you could use.
16 Feb 2011 by Venkatesh Mookkan
You need to implement INotifyPropertyChanged interface to your data object. WPF data binding power is mainly depends on the Notify Properties. If your data class doesn't have implemented it, it will not work as you said.You will get better idea if you read through this WPF: A Beginner's...
4 Mar 2011 by johannesnestler
Hi Apurva,This is one possible solution for this: Ignore the mouse-click in the client area of the ListView.using System;using System.Windows.Forms;using System.Drawing;namespace ListViewFocusDemo{ static class Program { class MyListView : ListView ...
17 Apr 2011 by Pete O'Hanlon
First of all, ICommand is not the mechanism to support events. It is the mechanism by which you should perform command based functionality in WPF or Silverlight. The reason I say this is because it goes beyond what an event should do - with commanding infrastructure, you can also affect the UI...
24 May 2011 by OriginalGriff
Never mind the select: how long does it take to fill? :wtf:30,000 items in any user interface is too many: how long is it going to take you poor user to actually find the one(s) they want?There only options are basically: select none, select all. They won't have the time or inclination...
1 Aug 2011 by UJimbo
ListView Remove function takes ListViewItem as a parameter. Remove .ToString() and try again
17 Sep 2011 by awaisdar
on Edit Linkbutton it fires the command but cant write " this.ModalPopupExtenderQ.show();" because its un accessible here.I want to edit the contents of "actual panel" in Modalpopup how can i assign the values of the labels of actual panel to the textboxes of Popup Panel???Please...
3 Oct 2011 by hzawary
Are you have this like error?Error: does not contain a definition for listView1_SelectionChanged; and no extension method;listView1_SelectionChanged; accepting a first argument of type; could be found (are you missing a using directive or an assembly reference?)If your answer is...
13 Dec 2011 by Anuj Banka
ON ItemDataBound this event will run for each row of the listview.And you can modify the data for each row and can access controls of each row.check this exapmle:If (e.Item.ItemType = ListViewItemType.DataItem) Then Dim divCatHeader =...
14 Dec 2011 by NandaKumer
try this bloghttp://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx[^]--NDK
27 Dec 2011 by Sergey Alexandrovich Kryukov
You English is fine; I wish other members could post their question in such a clear language free from ugly spelling mistakes. However, your problem looks artificial. You put some unmatched data in controls in first place and later wants to match items. Why?You should do the following: you...
28 Dec 2011 by Wendelius
Since it's a single select mechanism, another possibility would be to use checked list view. This way you wouldn't need two separate list views but the user would check/uncheck the items that are included.
28 Jan 2012 by Espen Harlinn
Have a look at ObjectListView[^]It makes what you are trying to do a lot easier :)In your case I think I'd use owner drawing [^]. Best regardsEspen Harlinn
18 May 2012 by Mehdi Gholam
Take a look at A Much Easier to Use ListView[^] which will do all this for you.
23 May 2012 by Mohamed Mitwalli
Hi , If you need to select the First Value you have to set SelectedIndex ListBox1.SelectedIndex = 0;Best RegardsM.Mitwalli
1 Jun 2012 by SASS_Shooter
What I ended up doing was (really) quite simple. It ended up being more of understanding syntax more than anything else.For my ListView I ended up having my definition implemented with specific brushes:
7 Sep 2016 by hansoctantan
I'm creating a program that downloads file from ftp server.Putting all downloaded files and downloading files in a ListView.I want to prioritize the downloading file so I want to add the item in first index.I try using this sample code but it doesn't work. 'FIRST DOWNLOAD With...
8 Jul 2012 by DamithSL
You need to set DataKeyNames of your ListView and then protected void lnkSuggestionStatus_Click1(object sender, EventArgs e) { ListViewDataItem item = (ListViewDataItem)(sender as Control).NamingContainer; string idValue=...
20 Aug 2012 by Clifford Nelson
You have two ways to associate Employees and Departments using objects. One is to have a Department property in the Employee object and the other is to have a collection of Employee objects in the Department object. You will also, at the minimum have either a collection of all Department or all...
26 Sep 2012 by Sergey Alexandrovich Kryukov
This is the popular question about form collaboration. The most robust solution is implementation of an appropriate interface in form class and passing the interface reference instead of reference to a "whole instance" of a Form. Please see my past solution for more detail: How to copy all the...
26 Oct 2012 by ridoy
I have done it myself.Splitting a name by space and then checking the index of the typed string..String[] word1=friends[i].split(" ");for(int a=0;a
24 Mar 2013 by WajihaAhmed
Figured it out . I hadn't included e.cancel=true; at the end of ItemUpdating event handler. Now it works perfectly inside update panel. The modified function is:protected void ModulesList_ItemUpdating(Object sender, ListViewUpdateEventArgs e) { //add data into the...
2 Apr 2013 by Richard MacCutchan
1. Use a local message code, something like:#define NM_SELECT (WM_APP + 1)and send it from one view to the other via SendMessage.2. you can use the LVS_EDITLABELS style to allow automatic editing of the item column, but I think you have to design your own handler for editing the...
15 May 2013 by Sergey Alexandrovich Kryukov
In For Each item As ListViewItem In ListView1.SelectedItems your loop variable is item. This is what you should use to extract data, but you are doing something else (I don't want to analyze what exactly, you are not using item, not even i, so it's all wrong anyway).And there is no a need to...
27 Aug 2013 by athira Paramesh
hai, i want to bind listview using json,bind data in clientside ...
3 Sep 2013 by Member 9822231
At design time set the ListView's Visible property to False. On button click event use the below to make the list visible.ListVW.Visible = true;
24 Sep 2013 by Dholakiya Ankit
protected void btndelete_Click(object sender, EventArgs e){ DataTable dt = new DataTable(); for (int i = 0; i
2 Oct 2013 by Azee
Hey there,I am not still sure about your problem, but here is what I think it is.You want the DropDownLists of the column have a selected value from the Datatype Column of the DataTable that the GridView is binding from.You can do two modifications and can make the selection this...
13 Oct 2013 by OriginalGriff
Simple: Arrays run from 0 to count -1Try: For x = 0 To lvsettings.Items.Count -1Instead.
18 Oct 2013 by Manoj K Bhoir
Use For Each Loop Instead of For LoopSee below modified code :For Each _mRow As DataRow In DataSetName.Tables(0).Rows Dim ls As New ListViewItem ls.Text = DataSetName.Tables(0).Rows(ct).Item(0) If ls.SubItems.Add(_mRow.Item(2))
20 Nov 2013 by Abdul Gafar
Hi,I need help in implementing this below:I have a list view containing students courseworks, one column holding the barcode IDs, one column holding subject code, one holding the coursework title and one holding the due dates.I want to have a button click event where by it checks the...
5 Jan 2014 by SukyCZ
Hello guys,First of all sorry for my bad english.Is there any way how to calculate in listwiev?I have a list view with two columns, ID and Number, using searching from text box.SEARCH BUTTONforeach(ListViewItem ID in listView1.Items) { if (search.Text...
5 Jan 2014 by Abhinav S
You can easily search the number within the listbox.Have a look at this[^] example.
5 Jan 2014 by BillWoodruff
Here's a simple illustration of how to search a ListView for a ListViewItem that matches a string, and how to get the match's SubItem, test to see if it is convertible to a number, and convert it to a number.private void button1_Click(object sender, EventArgs e){ ListViewItem foundItem =...
19 Feb 2014 by Sumit_Pathak
I am working on a project in which i need to implement Windows Explorer type list view as in different layouts like tiles,list,grid etc. There is an option to change the view style of windows explorer.I have been creating this with list view. But for performing this i have used multiple...
24 Feb 2014 by Dave Kreskowiak
Well, you HAVE to run the Office applications to print the documents. What else are you going to use to open the documents, parse them to render the page and printer them?? Without Office, you have no code that knows how to interpret and render the documents!You don't neccessarily need...
12 Mar 2014 by Peter Leow
Refer: ListView.CheckedItems Property[^]
8 May 2014 by King Fisher
You missed Class Selector a:hover{ text-decoration: none; font-size: 11px; font-weight: bold;}.mylink a:hover{ text-decoration: none; font-size: 11px; font-weight: bold;}
9 Jun 2014 by Dusara Maulik
Hi,You need to Google[^] this, you will find many solution.
9 Jun 2014 by Nirav Prabtani
try this.. :)listView1.Columns["ID1"].Visible = false;//orlistView1.Columns["ID1"].Width = 0;
9 Jun 2014 by goathik
is this what you mean by clear without removing? Let me know.listView1.SelectedItems.Clear();
7 Jul 2014 by goathik
you should continue trying your first approach with only a few modifications:First: You will need two arrays.It isn't your array which relies on the list, but the list must rely on the array, therefore just add the items to the list through a foreach on the array. At the start point,...
7 Jul 2014 by Zyvox
I don't know why I did not think of using a list instead. I swapped to a list, and thus it was much easier to debug aswell. I think my real mistake was that I messed up the arrays so it compared wrong parts or something.Nevertheless, I got it working now. Thanks!
7 Oct 2014 by Bhavik_Patel
Hey , you can take a look at Effective paging with List View control in ASP.NET[^]this article may help you.
14 Dec 2014 by themaystro2009
2 months struggling with these stuff, finally it's done 1st - imported JQuery files in this order 2nd -...
7 Jan 2015 by Sergey Alexandrovich Kryukov
It's better not to mess with XML or any other files by yourself, but to use serialization. Probably the best serialization method for you would be using Data Contract: http://msdn.microsoft.com/en-us/library/ms733127%28v=vs.110%29.aspx[^].This way, you can have any data model in the form of...
28 Feb 2015 by George Jonsson
The mistake you have made is to add two new items.Once in the line listView1.Items.Add(row.PIN.ToString())and once in the line listView1.Items.Add(lstItem)Change the code as below:listView1.Items.Clear(); FileHelperEngine engine = new...
2 Mar 2015 by AlwaysLearningNewStuff
INTRODUCTION:I am implementing rearranging of listview items without using OLE drag and drop.PROBLEM:I have successfully solved most of this task, except scrolling up/down when user wants to drop items at the position that is not currently visible.QUESTION:I am able to scroll...
25 May 2015 by Yesudass Moses
I want to fill a DropDownList in my ListView EditItemTemplate when Edit is activated. I tried this code. But, The EditItem is null, and it throws a NullReferenceException.protected void ListView3_ItemEditing(object sender, ListViewEditEventArgs e) { if (e.NewEditIndex >= 0 &&...
25 May 2015 by Santhosh Babu Mahimairaj
HiGood Day!!!Tyr to follow this......http://www.aspsnippets.com/Articles/Find-and-access-controls-in-EditItemTemplate-of-ASPNet-ListView.aspx[^]
31 Jul 2015 by jgakenhe
//This should be close. I can't test it because I don't have your datasource.//I took out the call to the database and stuck it in its own method.//Then after you delete, you refresh the grid with fresh data.protected void gotovieworder_Click(object sender, EventArgs...
13 Aug 2015 by Nav-CProject
I got 3 listViews 2 textbox and 2 buttons in WinForm.Program Description: The program adds numbers to the listview by typing in numbers in the textbox and clicking the add buttonGoal: I want to be able to use the IEnumerable.Except method to output only the unique numbers in listView3,...
2 Sep 2015 by Tirujit
Since you are trying to display the items belongs to a list in console, then you have to just execute a loop through the list items and just prints each list items based on their property names.foreach (var item in viewmodel.cleartriproom) { ...