TreeView with columns - c#

I need a multi columned Treeview for an app I am writing, I was wondering if anyone knew of a free working (in Vs-2010) multi columned Treeview.

There are a number of sample controls to be found around the web:
TreeViewAdv for .Net
TreeView with Columns
ContainerListView and TreeListView
But the all-time favorite is probably the ObjectListView, which provides an expandable, multi-column ListView, along with many other incredibly handy features:

You can use this example here or download this control

Try this Microsof TreeListView WPF control
http://msdn.microsoft.com/en-us/library/vstudio/ms771523%28v=vs.90%29.aspx

You can do an illusion to the user in the user interface.
Drag a listview and drop this over the treeview which was already placed in the form.
Create columns in the listview as you need.
Set the 'HeaderStyle' property to 'Nonclickable' and 'Scrollabe' property to 'False' of the listview.
Set width and location of the listview as it fits to the treeview.

Related

How to autogenerate columns in UWP XAML GridView or ListView?

In a Windows 10 UWP application I'd like to bind a collection of simple objects to a GridView or ListView and have the GridView or ListView autogenerate the columns based on the properties of the object rather than having to manually declare the columns and {Binding Path=SomePropertyName} on a TextBlock in the XAML.
This doesn't look possible.. is it?
Is there a different type of control other than GridView or ListView that will allow this behaviour?
Note: This is not WPF
TL;DR: This is not possible out of the box with the GridView or ListView controls.
In UWP a GridView is:
A control that displays data items in rows and columns.
The ListView is quite similar but only shows the items stacked in 1 dimension, by default vertical.
The DataGrid control (what this is typically called) is currently (as of SDK build 14393) not available in the default control set. With "some" effort you could write your own control for this behavior.
There are however multiple 3rd party solutions available, just google/bing for UWP DataGrid. Here are some of them:
MyToolkit.Extended NuGet package, more info on their GitHub page.
Libraries that might need a paid subscription/license:
SyncFusion
ComponentOne
Infragistics
You might find even more alternatives.
Can you write it in c# instead of xaml? Maybe it would be possible then, as long as you can access the container (gridview or whatever you use) beyond the constructor of your class. I'm not entirely sure if you can generate a new grid and switch on the fly but you could test it easily.

Placing controls on datagrid with WPF

I need a custom control element. I prototyped it and here it is on the picture. I think it is pretty self-explanatory. Could anyone suggest me how to organize it? I am not a WPF guru so if it will be working solution I'll better use it instead of doing by myself.
Sadly I can't post image, so it is here: http://imageshack.us/photo/my-images/521/control1.png/
Should I use datagrid with custom templates?
If so my question is how to populate row cells with custom contols and how to handle events on this controls to operate the RowId number?
How to apply custom templates for any individual cells? I found articles where templates applyed only for entire grid or column.
If anyone can help with this I would really appreciate it :)
I would suggest you to use ListView in grouping mode (with styles and templates)to accomplish this. Here are few samples doing similar to what you want to achieve -
ListView with grouping (In GridView mode)
Empty groups in WPF ListView
MSDN is also having one sample for this -
ListView Grouping Sample
I would personally use a TreeView. If your classes are already grouped properly ,you can then use HierarchicalDataTemplates to define how the TreeView works with each type. This will involve templates and triggers. Really, this will be mostly xaml, with very little event coding.

Select cell values inside a Listview - Details View

I am creating Windows Forms application using C# .NET in Visual Studio 2010.
I populate data to a ListView from a Excel file. Now I wanted to select a particular cell or list of adjacent cells vertically. I have attached a sample image here:
I wanted do something like this inside a ListView.
I need suggestion from you to understand the methodology (like what are events I should use, what properties of the ListView I should change to do this, etc.)
I appreciate any help you can give.
A ListView control is a poor substitute for a grid control. You can simulate this by tinkering with ListViewItem.UseItemStyleForSubItems = false, the sub-item's BackColor property and ListView.HitTest() but that isn't any fun. Consider DataGridView or one of the many spreadsheet and grid controls available from 3rd party vendors.

Custom items in ListView control

I need to add a custom item to ListView control (like on the picture), is it possible ? And if it is, what's the best way to do it ?
I don't know that this is possible with Winforms. The list items in a System.Windows.Forms.ListView are System.Windows.Forms.ListViewItem objects contained in a strongly typed collection.
You could try to create a subclass of ListViewItem, but since that class inherits directly from System.Object and is not an actual windows form control, you might be borrowing trouble, as you would need to replicate all the functionality of the inheritance chain of an actual control.
Now, if you are not too far in to the project, you might consider looking at switching to WPF. The ListView in WPF uses controls as items, so you could easily create a usercontrol that you would use as your list items.
You might be able to find a control library with a control that gives you the functionality you want, but for the most part, the good libraries are commercial and can be prohibitively expensive for small shops and individual .
I did a quick google search for any library that offers this capability, but I could not find one that displayed custom controls.
Not sure if this is what you're after, but ListViewItems have a Tag property that can store custom data about each item.
http://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.tag.aspx
How about creating a user control. In that case you can set your user controls at the top and listview below. Or are you trying to add these controls as items in the listview itself?

Rearrange items in ListBox

I have a ListBox with a number of ListBoxItem objects. What is the best way to allow users to rearrange the items by dragging and dropping? Do I have to use StackPanels instead?
Thanks for any suggestions
You are going to use a different listbox control or build your own. Here is an example of building your own. Here is another one where he extends the silverlight toolkit listbox control.
For prosperity, the Silverlight Toolkit offers a set of DragDropTarget's which can be used to reorder items within a ListBox, TreeView, or a simple ItemsControl. You can also drag items between ItemsControls. Run the Silverligh 4 samples project and look at 'Drag and Drop' under the Toolkit section.
http://silverlight.codeplex.com/
http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html
The controls you want are:
ListBoxDragDropTarget
TreeViewDragDropTarget
DataPointSeriesDragDropTarget

Categories