Multicolumn listview with expandable items when clicked - c#

So i have a datagrid that was built with the mindscape datagrid control that looks like this:
I am not sure if i will be able to do this to the mindscape control, so this will be a question about any multi-column listview or datagrid.
When an item is clicked, and selected, I need to expand the item (hopefully with an animation/storyboard) downwards, to display a bunch of extra information about the item (rating graph, list of available locations, etc).
I honestly have no idea how to begin with this. I'm new to wpf. in winforms i would just create a custom listboxitem that controls it's own height, and listen to the selected event.

A ListView is not the best control to use for your requirements. Instead of the ListView, you should use a DataGrid control. Your required functionality is built in to the DataGrid as it has a row details section... from the DataGrid.RowDetailsTemplate property page on MSDN.
You can customize the data presentation in the DataGrid by adding a row details section. Adding a row details section enables you to group some data in a template that is optionally visible or collapsed.
You define the row details template as either inline XAML or as a resource. A data template that is added as a resource can be used throughout the project without re-creating the template. A data template that is added as inline XAML is only accessible from the control where it is defined.

Related

Displaying a collection of controls in Windows Forms

I want to display something like the following :-
Each row is about a process (information like PID, Parent etc.). User can check the checkbox and click Launch button to get some dynamic details about that process.
The problem is that CheckedListBox control doesn't allow more than one columns and other controls like ListView (which allow multiple columns) don't allow controls like checkbox to be embedded in a columns.
I want to know if there is a control which will allow me to have a list of custom controls where each custom control contains a checkbox, Some Text and Some Dynamic Text.
How can this be achieved in Windows Forms? Thanks in advance.
You can use either of these options:
DataGridView (Example)
You can use DataGridView to show multiple columns of different types, including TextBox, Label, CheckBox, ComboBox, Image, Button, Link. You also can customize appearance of the grid by custom painting or adding new custom column types.
UserControl
You can create a composite control or UserControl containing any other controls which you need and use it as a row template, then you can show all rows by hosting multiple instance of that user control in a Panel or FlowLayoutPanel.
TableLayoutPanel (Example)
You can use a TableLayoutPanel containing multiple columns and rows. Each cell of TableLayoutPanel can host a control.
DataRepeater
You can use a DataRepeater control to create a row template and show a list of rows using that template.
Example 1 - DatGridView
If you want to use data binding and show specific controls including TextBox, Label, CheckBox, ComboBox, Image, Button, Link a row, DataGridView is great. It's customize-able and you can add some other different column types or customize painting of the grid or benefit from wide range of useful events for validating and so on.
In following image you can see a DataGridView with RowHeaderVisible and ColumnHeaderVisible set to false to act like a List of fields without header:
Example 2 - UserControl
If you need custom control to host more complicated controls or having more control on components or show them in a different layout than columns, you can create a UserControl hosting your components, then:
If you only want top-down flow, Use a Panel and add your user control to it with Dock property of control set to Top.
If you may want flows other than top-down Use a FlowLayoutPanel to add instances of your control to it.
Create a UserControl
Add instances of it to your Panel or FlowLayoutPanel
You could use the TableLayoutPanel container.
I want to know if there is a control which will allow me to have a
list of custom controls where each custom control contains a checkbox,
Some Text and Some Dynamic Text.
One option could be that you create the following as a separate user control,
...and as container control use container like FlowLayoutPanel and keep adding the user control into the FlowLayoutPanel.
Make sure that the direction of FlowLayoutPanel is set TopDown
this.FlowLayoutPanel1.FlowDirection = FlowDirection.TopDown;

Accommodate custom item on winrt listview

I'm developing windows metro app. In my application, I've one Listview with wrapgrid in itemspanel to display list of items on vertical rows with specific height. I want to display one item on top of the first column of list view, which shows result/stats of list items.
I would like to know if it is possible without adding custom item to datasource of listview?
ListView has a Header property in which you can Place content before the ListViews Items.
As commented, I've implemented following solution which is not elegant but worked for me.
Use Datasource converter to add dummy item in main list. So, my original list remains as is.
Use Template Selector to bind different template for first item.
Handle Selection and clicked event of dummy item.

Silverlight Accordion. Can I bind to set of controls with different styles?

I have list of some data items. Each has a method GetStyle which returns ControlTemplate. Previously I was building a custom panel and adding the items as controls into children.
Now I need to group the items and I want to use accordion but I need to find out how can I inject my own template for each item on binding.
Alternatively I can split the items into several panels and add them to the accordion (avoiding data binding) but not sure how either.
I'm using Silverlight 5.
What I have done to make it work:
Created lookless control
On either Load or ApplyTemplate I inject ControlTemplate into the
control
Created Accordion content item template as
...
Bind Accordion data source to the list of items which has
knowledge on what template has to be created.

multicolumn combobox just like a combobox in winforms

i have developed a user control for winforms in C#.Net framework 3.5, it is multi-column combo, named 'DataCombo'.
i have created it with the help of Textbox and DataGridView, it looks like a combobox, and also behave as it, cursor jump on textbox list will appeared, the only difference is, that combobox provides only one column, and in this 'datacombo' we can show more than one column,
and we can provide facility like sorting (just like a explorer), filter, column re-ordering etc.
this is very useful component to me.
my problem is that, when i put this control to a frame or groupbox or any container control, and my list size is more than container's size, than list will cut off as container size,
i want this component should behave like a combobox when we put a combobox and its list size goes to out of container, although the list appears correctly
any suggestion how could it do this
i want some like this
Turn off the visibility of dataGridView in UserControl and set following properties of UserControl in design mode.
AutoSize=True
AutoSizeMode-GrowAndShrink

How do I create DataGridViewComboBoxColumn that has a grid-like drop down?

I am in need of a DataGridViewComboBoxColumn that displays a multi-column grid drop down, similar to the one described here. Basically, I need to override the DropDown event of the underlying ComboBox. The example at the bottom of this page shows how I can add event handlers. But, I need to override the showing of the drop down. I'm guessing I need to create my own ComboBox class but how do I connect that with a DataGridViewComboBoxColumn? Has anyone done something similar?
This looks like a winner
.NET datagrid is a graphical user interface component that presents a tabular view of data. .NET datagrid supports the following common interface features:
Clicking a column header to implement grid sorting
Dragging column headers to change their size
In-cell editing of shown data
Row and column separators, and alternating row background colors
Datagrid's cells can be presented as some different control types (textbox, button, date/time picker etc.) within datagrid interface layout. However much important control is combobox that could be placed in datagrid...
I ended up finding the following on MSDN that outlines how to create a custom DataGridView column. This includes creating a cell type, a column type, and an Editing control type. I ended up using a ListView control inside a form with no borders as my drop down grid.
http://msdn.microsoft.com/en-us/library/aa730881(v=vs.80).aspx

Categories