I use SQLite3 to read data from a database and then display the results in a listBox, I would to ask if there is possibility to display the results in a listBox as columns in nice show without using DataGrid.
It is better to use ListView instead of listBox.
Also you can still use listbox for multicolumn purpose
Listbox is not designed to work with multiple columns. Any reason why you do not want to use a DataGrid?
In general a grid control is the most appropriate when dealing with items or records having multiple properties or fields to be shown in different columns, some people also use a ListView with the report/details style and several sub items one per each column.
In my experience when the final result is really a table/grid it is easier and simpler to use a grid instead of "forcing" a ListView to behave like a grid. ListView is not designed for that even if it can be used in a similar way.
Related
I would like to Know whether this is a dataset, datagridview or list view and also would like to know how to make on like this
DataSet => The data that you use to attach to the grid. Will itself contain a collection of DataTable
DataGridView => The control that shows the data. Is effectively a collection of column templates, and using those will marry up to the DataTable or DataSet you set as the DataSource to the control.
ListView => These are the repeater controls you can use like a drop down list, they display elements of a collection via a template for each item, allowing the user to select/focus an item or multiples thereof.
To make one like the one you showed, you can use WinForms, which is probably the easiest to learn too! There's a million resources on the internet for this, Google is your friend, and I'll give you a headstart here.
To directly answer your first question, it's actually ALL THREE of those things!
I am quite new to WPF and XAML but my background is of ASP.NET and C# so I have a vague idea of how it works.
In .net, I can use the repeater, datalist, gridview, bind to them a DataTable and output from that DataTable. I am now wanting to do the same with WPF.
Basically, I want to display simple records from a database (preferably using a DataTable as I usually work with those). The list might be something like this with two columns
1) Grey TV
2) Red car
3) Blue motorbike
I have looked around but I can't get a definitive answer on what control to use. Some people say ItemsControl and some people say DataGrid. Can anyone help me here?
Thanks in advance.
A DataGrid is used for displaying Table-like data (Per record multiple columns). An ItemsControl is used to display data using your own ItemTemplate, in which you are unlimited in how to represent the items and in what directions or alignments.
Another good useable control for you might be a ListView, which works just as a ListBox except it doesn't have any selection logic. And you can choose between four different ways of displaying your items using the View property (http://msdn.microsoft.com/en-us/library/system.windows.forms.view.aspx).
In your case I would suggest using a ListView.
To bind any items to the control, you have to set the DataContext on the UserControl or the Control itself. And then bind the ItemsSource property to a local List or Collection using the Binding markup extension (http://msdn.microsoft.com/en-us/library/ms750413.aspx). To learn more about data-binding go here:
http://msdn.microsoft.com/en-us/library/ms752347.aspx
I'm binding to an ienumerable(items) in my MainViewModel to display data. As i've described here before How to change the content in a datagrid or listview using MVVM, all i want to do is display different tables. My first approach was to use the normal datagrid and set the "AutoGenerateColumns" to true, so that the correct columns are displayed. As it turns out, performance was pretty bad so i switched to ListView and GridView, but since there is no "AutoGenerateColumns" available i need to somehow create and change the columns.
So how would you do it?
Have a look at this question for something that comes close to -- but is not -- auto-generation: WPF GridView with a dynamic definition.
Generally speaking, autogenerating means doing reflection on the ItemsSource, which can get messy since it needs to cover a huge number of possibilities correctly.
What is the best way to display multi-columned data in a grid format using C# WinForms?
Is it ListView or DataGridView?
DataGridView is your best bet for simple grid display. However, if you are needing nested (collapsible/expandable) display for child rows, etc. DataGridView will not do that.
The ListView would be good for something like the way Windows Explorer displays objects, properties, files, etc.
datagridview is the choice , its shows data in grid format, also supports operation like sorting, filtering which is required by lot of apps nowadays
How do I display a DataGridView within a cell of another datagridview in C# forms app?
How would I have to handle Sorting & value changed if this possible?
That is the only way I can display data to make some sense.. Think of it like I have a task column and dates column. Under the dates column I have a list of things to be done. These date columns are dynamic & there might be multiple date columns
That sounds like a difficult interface to use, have you considered some kind of tree control?
If you're determined to use data grid views, look at customizing data grid view columns and cells. You need to declare custom subclasses for the column and cell behaviour that you want. I don't know if it's possible to do what you want, but that's where I would start.
This is a suggestion since what your asking I do not think is possible with the built in DGV of .NET.
Using custom controls made by professional companies that provides a DataGrid with the capability of hierarchical data. For example a row can be expanded to show multiple entries (the multiple entries can be an entirely different table containing completely different columns even). Here are a few options that you can check out.
Infragistics WinGrid
Component One
There are a few other places/companies that make great .NET component packages that provide added features to the existing .NET components.
http://blogs.msdn.com/markrideout/archive/2006/01/08/510700.aspx
Found a link where hierarchichal datagrid is implemented.
Now, I have to either modify the control, or settle for hierarchichal gridview!
Hope this helps someone. Will update later