Displaying Tabular Data In A WinForm? - c#

I started with using a TableLayoutPanel, but when I have big tables, they are extremely sluggish. I'm looking for the responsiveness of an HTML table to display my data in.
The only solution I currently have is to have my WinForm write and HTML table, and display it in an embedded browser. This obviously is a huge workaround, and I'd rather implement a more clean and straightforward solution.
If you have any suggestions, please fire away. (a ListView will not work for what I'm trying to do)

What about using a DataGridView, or if you have DevExpress, a XtraGridControl? TableLayoutPanel is designed for laying out controls as far as I know, not for presenting data.
On the other hand, if your data set grows as large that your tables become sluggish, you might want to narrow down your data, e.g. by filtering or by introducing paging, one page only displaying 50 items or so.
Paging as well as filtering, in turn, is supported at least by XtraGrid, not sure about Microsoft's DataGridView.

You definitely need either a grid or a report, depends on what you want.
Highly customizable grid controls (like Infragistics or DevExpress) allow you to make almost any appearance you need. Users will have no idea they look at grid control.

Related

Achieving Excel like functionality in WPF

I am struggling with achieving a requirement on a current system.
The system is intended to manage costs and project details and is currently provided through an Excel based solution. Each project consists of a number of weeks which are represented by columns, with a variety of data items presented on the rows. Project lengths are such that many projects have in excess of 150 columns. Columns and data items can be added dynamically, and the user wants to be able to navigate quickly around the grid using keyboard controls.
The business is moving from this unsupported Excel based solution to an application written in C# with a WPF front end, but the users still want a solution close to their existing spreadsheet.
I have initially tried to implement this using the Telerik WPF grid control that I have used elsewhere using dynamic/expando objects to hold the data and using the AutoGeneratingColumn event to create the controls for each of the columns. Initially the performance was acceptable but I had to turn off column and row virtualisation to enable the user to be able to tab through the fields, and this has resulted in a dramatic reduction in performance particularly when adding new rows and using filtering.
Is a grid control the right method to accomplish this requirement – could another third-party grid handle the dynamic column creation better - or is there an alternative design that could achieve both the performance and user interface requirements?

What WPF control should I used to build a high performance grid?

What WPF control should I used to build a high performance grid?
I want to be able to have cell level control so I can update a cell and have the grid only redraw that cell.
The DataGrid doesn't seem to give cell level control.
I need to support 10000 rows with lots of cell updates (say 200 per second).
Thanks
If you dont want to try 3rd party data grids then did u atleast give WPF Datagrid a try? It does support virtualization at row and column level. Plus cell level control is available thru CellStyle for DataGridCell type. You can even attach any behavior to DataGridCell and then gain exclusive access over it and drill into its visual tree and perform any kind of performance improvements you want locally to its contents.
I have been using WPF datagrid for various requirements (hierarchical data display without row definitions and group styles, frequent data updates, large number of columns, frequent editable and validation based scenarios, adorning virtulaized cells and deferred scrolling with guesswork for scroll heuristics etc..)
You can play around with it to the fullest. Codeplex website has source code of last toolkit based WPF data grid available.
Let me know if this helps.
IF you need performance, your best option is to measure, measure, measure.
Build a quick prototype using each of the DataGrid classes you're looking at, using "realistic" sample data.
See which ones perform well, and which ones don't.
The Telerik RadGrid for WPF supports both Row- and Column-Virtualization and might be what you are looking for.
I'd not refuse a-priori a winform-approach since the huge amount of data and the relatively high speed of the updates. In a similar scenario, you may manage even much more data without affecting the performance significantly.
I'm a big fan of WPF, but not always it solve all the problems.

C# datagrid vs DevExpress XtraGrid, speed wise

I have a program that loads 10,000 rows into a datagrid and the datagrid can be slow to render/paint and occassionally doesn't display, you can tell it has loaded with data but the grid goes blank. I was thinking of replacing the datagrid with DevExpress XtraGrid, has anyone used this and can I expect it to render/paint quicker?
Thanks
PS This is a win form app, there are probably less than 10,000 rows in reality but safe to say a lot. I suspect we need to use paging maybe?
We use the standard DataGridView with hundreds of thousands of rows and dozens of columns with instantaneous performance, no problems at all. In Virtual Mode. Use Virtual Mode.
http://msdn.microsoft.com/en-us/library/2b177d6d.aspx
First off, make sure you are using Virtual Mode with your GridView
From Data Display Modes in the GridView Control:
The primary use of virtual mode
... is to optimize performance
when interacting with large amounts of
data.
MSDN has a tutorial to get you started...
My first spontaneous thought is that it doesn't matter which grid is faster, since 10000 rows in a grid in a user interface feels like an error in itself. But then again I don't know what the application does so it may make sense in the context in which is it used...
Anyone that is looking for a good alternative to the standard datagrid should give SourceGrid a try, it is free and quite well done.
I'm fairly certain that you won't notice a significant improvement by switching. I think the problem is the sheer amount of data you are pushing into the grid (and thus down to the browser).
Can you page this data, or do all 10000 rows have to be on a page? If its the latter, I would consider using a repeater control. If paging is an option, I would suggest pushing the paging back to the data source.
Either should garner you a decent improvement.
3rd party grids can make ajax updates and db-side paging easier, but there is a big learning curve with each one, and formulating the right query isn't that hard if you want to do it in plain old .net.

What is a fast way to render a log view in WPF?

I'm writing an application that needs a log-like view, (similar to how an IM client displays messages in the conversation), with potentially many updates per second. Speed is an issue here; the application locking up due to a large number of incoming events is a possible problem. I need selection and basic text formatting, so manual rendering could get quite complex, I'd like to avoid it if possible. I'd also like to bottom-anchor the scroll bar, that is, if it's at the bottom, stay at the bottom when the new item is added. What would be a good way to implement this?
You can implement it very easily in WPF.
Create an ObservableCollection of Log entities and bind to a ListBox.
Give a DataTemplate for the ListBox.ItemTemplate.
*When running in real time you need either UI side or Data side virtualization
Check out my PaginatedObservableCollection so that the DataVirtualization will automatically function.
I think you should have a look at ListView/ListBox controls, they support UI virtualization and provide functionality you're looking for. Also you can improve performance by data virtualization/lazy loading - i.e. don't hold invisible items in memory and load required data on demand

alternative to DataGridView in Win API

Somewhere on net on one Blog I read a sentence that is "DataGridView something like Boeing 777, but what is goal when I do not know how to fly.
Before I goo deep in creating my projects I wanna know is there alternative for DataGridView in C#.
Something like jQuery in WEB api.
The favors things which I am looking for is that is simple for using, if its posibile to be freeware and looks smoth and modern.
Best regards
Admir
If you want to fly one person across town you can learn to fly a Piper Cub. If you want to fly hundreds across an ocean you need to learn to fly a 777.
There are many ways of displaying data in WinForms applications; which one is best for you depends on what you're trying to do. If you want to show a fixed, non-editable, non-scrollable list of data you can use a DataList; simple and limited. If you want to add scrolling you can output the data to a scrolling textbox.
If you want to handle a scrolling grid of multiple rows with multiple, resizable, editable columns you will need to move to a DataGrid or DataGridView.
There are many alternatives to DataGridViews; simpler controls provide fewer features and more functional controls are more complex.
I have implemented the datagridview extensively as an unbound control in a windows forms project using Visual Studio 2008. Looking back, implementing this control has consumed a large amount of time, mostly because it is loaded with bugs and peculiar behavior that should have been fixed rather than just 'documented'. A good data grid control is essential to any application of substance. I would recommend looking for a third party alternative from a company that is more interested in getting it right rather than just getting something out there.
The DataGridView is perfectly easy to use without going too deep. If all you want to do is display data in a grid, create a DataGridView and turn off features like adding and editing rows. The fact that it's got all of these incredibly complex features is really only an issue when you start needing to use them - and in that case, you'll be glad you're using it.
DevExpress has a really good gridview.

Categories

Resources