Dynamic grouping in a WPF ListView - c#

I have a list with some items.
The items have a name, creation date, modification date, an owner and some other properties.
I want to diplay them in a WPF ListView and group them.
They shall be grouped a column selected from a dropdown (no grouping, group by name, group by owner, group by creation date).
I know how to bild a list view, bind the item list and createing a static group. There are a lot of good examples fpr static groups.
I need enabling/disabling grouping and changing the group.
How can ythis be done in WPF?
Clemens Hoffmann

Related

Group items by date in a listview

I would like to create groups by day for my items in a ListView (like a LongListSelector in WP7). I succeed with alphabetical items thanks to the CharacterGroupings class but I try to find the best way with timestamp. Do you have any idea to help me sorting items by creating by month/day, then put all the relating items in these groups ?

WinForms XtraGrid column filter checked listbox actual data

Y've already helped me a lot. But I have another trouble.
I have an XtraGrid with data. Two columns configured to show checked list box for filtering. For example one column for States and other for Cities. This listboxes contains column data, so user can check multiple values and grid will ilter up its view.
But when you choose filter in first column (for example one State) and then open second column filter its listbox contains all data (with all available Cities, but not the Cities from filtered State) from grid but not from currently filtered view.
Is there any method to update filter checkedlistbox to show only currenlty visible values for column?
You can achieve such functionality by setting ShowAllTableValuesInCheckedFilterPopup to false.
More on the subject here: https://documentation.devexpress.com/#windowsforms/DevExpressXtraGridViewsBaseColumnViewOptionsFilter_ShowAllTableValuesInCheckedFilterPopuptopic

How to use ensurevisible method in listview?

I have a ListView contains 100 items, and we can do certain activities based on selected items. I have used EnsureVisible() method to adjust the visibility and my ListView refreshing time to time to update the data.
The problem now i am facing is if I select the first item in the list, I then start paging down (maybe select the 21th, 59th
and 75th) during this select, I could have highlighted the 1st, 24th and
56th when the control suddenly refreshes the page in this instance, only the 1st selected retains the focus and I have lost my other selections and have to go through again either individually or just quicker.
So my question is how i can select multiple items and do the action while ListView is refreshing during certain interval to fill data though EnsureVisible() is used?
This is my exisitng code:
if (_listviewFirst.SelectedItems.Count > 0)
{
_listviewFirst.SelectedItems[_listviewFirst.SelectedItems.Count - 1].EnsureVisible();
_listviewFirst.SelectedItems[0].EnsureVisible();
}
I would use the ListView.ItemSelectionChanged (MSDN) event and add/remove items (or their references) from a List of selected items. When your control is refreshed you should then iterate your selected items and update the items to selected in your ListView.
You will be able to take advantage of e.IsSelected and e.Item or e.ItemIndex in the event handler to do this.
I wouldn't use EnsureVisible at all for this.

Sitecore sub-items sorting issue

When there is no sorting of sub-items selected, what is the default sorting method? According to the sitecore documentation:
"If you do not specify a child sorting rule for an item, Sitecore applies the Default child sorting
rule, and users can sort items manually."
and it defines default as:
"Default: Sort items alphabetically by name, not interpreting leading
digits as numbers. Leading underscores sort last. This is
the default child sorting rule."
However, I have a script that enters a bunch of items, and I just want them to show in the order I entered them in (which is essentially the 'created' option) - and then I want the user to have control over how they order it after that. Unfortunately, it doesn't preserve the order I entered them in (and doesn't seem to be the default either).
If I choose any of the sub-items sorting option, then the user can't order it anymore... how can I do this? Is there someway to set the starting sort-order, and then still have the user order the items?
What you should do is leave the Subitems Sorting field empty, then add a sort order value (in the __Sortorder field) to each of your items that are being inserted by the script (increase the value by 100 for every item, starting by 100).
That should result in what you want; your items sorted by order of insertion and users can still change their order in the content editor.

How To Hide ListView ColumnHeader?

I am struggling to figure out the correct control to use for a list of predefined jobs in the included form. I currently have a ListBoxControl in the Predefined Job Name group that lists all of the predefined jobs for a marine service shop (i.e. oil change, tune up, etc...). Then, based on the item (i.e. job name) that is selected in my ListBox, I need to display the items that correspond to that job. For example, if oil change is the selected job I need to show 4 quarts oil, 1 oil filter, labor, etc...and so on.
Currently, when I load the form data I have a DAO that retrieves all of my jobs from the database using LINQ to SQL. Then I iterate over the results and put the job names into the ListBox. The problem that I am having is that there is no tag for ListBox items like there is for ListView items. So each time the user selects another item in the ListBox, I have to perform another LINQ query to get the job from the database again so that I can display its' corresponding items. If I could use a ListView and hide the column header I could set the entire job on the tag so that each time the user selects a new item I would have access to the details without having to make another call to the database. Is there a way that I can hide the column header of a ListView without hiding the entire column?
You can set the HeaderStyle member of the ListView to None.
listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
Checkout the ListView HeaderStyle property. It has the following options:
None
Nonclickable
Clickable
From MSDN:
The HeaderStyle property allows you to specify whether the column headers are visible or, if they are visible, whether they will function as clickable buttons. If the HeaderStyle property is set to ColumnHeaderStyle.None, the column headers are not displayed, although the items and subitems of the ListView control are still arranged in columns
You can also create simple object like ListItem which has two poperties: Text (string) and Tag (object). Then implement ListItem.ToString() and you can use these in the ListBox as well.
You can also check out Better ListView Express component, which is free and allows displaying items in Details view without columns. The advantage over ListBox and ListView is a native look and many extra features.
Easy way is using the ColumnWidthChanging event
private void listViewExtended1_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
{
if (e.ColumnIndex == 0)
{
e.Cancel = true;
e.NewWidth = listViewExtended1.Columns[e.ColumnIndex].Width;
}
}
I found that if you know for a fact you are not displaying the headers it may be best to set the HeaderStyle property to None, as Rajesh mentions above.
When setting in the .CS when screen initially loads the headers are displayed until screen is fully rendered.

Categories

Resources