listview

Can I create a ListView with dynamic GroupItemCount?

I'm using the new ASP.Net ListView control to list database items that will be grouped together in sections based on one of their columns like so: region1 store1 store2 store3 region2 store4 region3 store5 store6 Is this possible to do with the ListView's GroupItemTemplate? Every example I have seen uses a stat...

Disabling a ListView in c#, but still showing the current selection

I have a ListView control, and I'm trying to figure out the easiest/best way to disallow changing the selected row(s), without hiding the selected row(s). I know there's a HideSelection property, but that only works when the ListView is still enabled (but not focused). I need the selection to be viewable even when the ListView is disabl...

How can I convert IEnumerable<T> to List<T> in C#?

I am using LINQ to query a generic dictionary and then use the result as the datasource for my ListView (WebForms). Simplified code: Dictionary<Guid, Record> dict = GetAllRecords(); myListView.DataSource = dict.Values.Where(rec => rec.Name == "foo"); myListView.DataBind(); I thought that would work but in fact it throws a System.Inva...

Is there an event that triggers if the number of ListViewItems in a ListView changes? (Windows Forms)

I'd like to enable/disable some other controls based on how many items are in my ListView control. I can't find any event that would do this, either on the ListView itself or on the ListViewItemCollection. Maybe there's a way to generically watch any collection in C# for changes? I'd be happy with other events too, even ones that someti...

[ASP.NET] How to access controls in listview's layouttemplate?

How do I set a property of a user control in ListView's LayoutTemplate from the code-behind? <asp:ListView ...> <LayoutTemplate> <myprefix:MyControl id="myControl" ... /> </LayoutTemplate> ... </asp:ListView> I want to do this: myControl.SomeProperty = somevalue; Please notice that my control is not in ItemTemplate, it is in Layout...

Win32 List-View Control SubItem padding for custom-drawn SubItems?

When using custom-draw (NM_CUSTOMDRAW) to draw the entire contents of a ListView SubItem (in Report/Details view), it would be nice to be able to apply the same left and right padding in my custom paint method that is applied by the control itself for non-custom-drawn items. Is there a way to programmatically retrieve this padding value...

.NET ListView row padding

There doesn't seem to be a way to change the padding (or row height) for all rows in a .NET ListView. Does anybody have an elegant hack-around? ...

Listview background drawing problem C# Winform.

I have a little problem with a Listview. I can load it with listview items fine, but when I set the background color it doesn't draw the color all the way to the left side of the row [The listViewItems are loaded with ListViewSubItems to make a grid view, only the first column shows the error]. There is a a narrow strip that doesn't pa...

Does anyone know of a way of hiding a column in an asp.net listview?

I know you can put <% if %> statements in the ItemTemplate to hide controls but the column is still there. You cannot put <% %> statements into the LayoutTemplate which is where the column headings are declared, hence the problem. Does anyone know of a better way? ...

How to set the header sort glyph in a .NET ListView?

How do i set the column which has the header sort glyph, and its direction, in a .NET 2.0 WinForms ListView. Bump The listview is .net is not a managed control, it is a very thin wrapper around the Win32 ListView common control. It's not even a very good wrapper - it doesn't expose all the features of the real listview. The Win32 list...

Is it possible to base GroupTemplate (.NET) on anything but a fixed record count?

I'd like to use ListView to display grouped data from my db. Because of the way the query is structured, each logical group might have 1 or 2 records associated with it. Is there anyway to use GroupTemplate, while overridding the GroupItemCount behavior? Ideally, I'd like it to behave the way SQL does- assign a column ID, and let it watc...

How to avoid thousands of needless ListView.SelectedIndexChanged events?

If a user select all items in a .NET 2.0 ListView, the ListView will fire a SelectedIndexChanged event for every item; rather than firing an event to indicate that the selection has changed If the user then clicks to select just one item in the list, the ListView will fire a SelectedIndexChanged event for every item that is getting unse...

How to SelectAll / SelectNone in .NET 2.0 ListView?

What is a good way to select all or select no items in a listview without using: foreach (ListViewItem item in listView1.Items) { item.Selected = true; } or foreach (ListViewItem item in listView1.Items) { item.Selected = false; } i know the underlying Win32 listview common control supports LVM_SETITEMSTATE message which you can ...

How to prevent flickering in ListView when updating a single ListViewItem's text?

All I want is to update an ListViewItem's text whithout seeing any flickering. This is my code for updating (called several times): listView.BeginUpdate(); listViewItem.SubItems[0].Text = state.ToString(); // update the state listViewItem.SubItems[1].Text = progress.ToString(); // update the progress listView.EndUpdate(); I've see...

How can I access the ListViewItems of a WPF ListView?

Within an event, I'd like to put the focus on a specific TextBox within the ListViewItem's template. The XAML looks like this: <ListView x:Name="myList" ItemsSource="{Binding SomeList}"> <ListView.View> <GridView> <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> ...

How to scroll only the right side of a table, listview, or datagrid?

Let's say I have data structures that're something like this: Public Class AttendenceRecord Public CourseDate As Date Public StudentsInAttendence As Integer End Class Public Class Course Public Name As String Public CourseID As String Public Attendance As List(Of AttendenceRecord) End Class And I want a table that looks som...

Retrieving multiple rows into a listview control from an ODBC source works well for simple SELECTs with a statement attribute of SQL_SCROLLABLE. How do I do this with a UNION query?

I am retrieving multiple rows into a listview control from an ODBC source. For simple SELECTs it seems to work well with a statement attribute of SQL_SCROLLABLE. How do I do this with a UNION query (with two selects)? The most likely server will be MS SQL Server (probably 2005). The code is 'c' for the Win32 API. This code sets (wha...

Associating a ListView with a collection of objects

How can you use a ListView to show the user a collection of objects, and to manage those objects? ...

Listview icons show up blurry (C#)

I'm attempting to display a "LargeIcon" view in a listview control, however the images I specify are blurry. This is what I have so far: The .png files are 48x48 and that's what I have it set to display at in the ImageList properties. There's one thing that I've noticed (which is probably the cause) but I don't know how to change it. I...

Create WPF ItemTemplate DYNAMICALLY at runtime

At run time I want to dynamically build grid columns (or another display layout) in a WPF ListView. I do not know the number and names of the columns before hand. I want to be able to do: MyListView.ItemSource = MyDataset; MyListView.CreateColumns(); ...