Advice on datastructure - c#

I was looking for some advice on what options are possible to create an interactive table similar to the image below with C#4.0 WPF.
Essentially I want some fixed data displayed on the left and based on user input the remaining data recalcs based based on selections
I was thinking a datatable has about 95% of the functionality I need but I can't find many resources or info on adding controls to make it interactive or if what I'm considering is a dead-end.
I've currently got new datatables being generated based on selections elsewhere and displayed in Winforms DataGridView but it makes it difficult to compare so I really wanted to make it more interactive. For WPF I'd hoped there would be something nicer.
My questions are, can a datatable do this? Are there any better alternatives?
Additional Info:
The data doesn't come from a database, or a single source.
It doesn't need to be saved anywhere either
The columns and rows are not fixed

A DataGrid can of course do this for you, similar to WinForms DataGridView.
For the backend you have many choices but to accommodate runtime flexibility the good old DataTable might still be a good choice.
Probably link it through a CollectionViewSource

Related

Export WPF datagrid to PDF-file

I'm writing an program in WPF that puts data from an mySQL-database into an datagrid.
The data that comes out of the database, is saved in an list of objects.
This list is the datasource for the datagrid.
Now i want to save this content to a PDF-file.
What's the best solution to do this?
The best solution depends heavily on your specific requirements. A few of the things you should think about when considering a solution are:
How important is performance? If this is a server side task (probably not based on your info above) then you would really care about high performance to minimize load on your server.
How much customization of the reports do you need?
Do you need the report engine to format the data beyond what comes back from MySQL or the container object being used to transport the data? For example, currency, percentages, etc ...
What is your budget? Do you have room for a paid solution?
In general, there are a lot of solutions out there. Some of them will even take a standard DataTable or DataSet and generate the report from that. Typically though, with a solution like this you lose some level of customization over the report in exchange for the ease of implementation.
I personally have used iTextSharp in the past. It is really easy to generate a table based on your tabular data and you maintain absolute control over the PDF document being generated. Unfortunately, iTextSharp appears to have moved more into the private sphere and isn't really practical for most uses due to their ridiculous pricing and requirements on the Community Edition.

How to best add HUGE amount of data to DataGridView

I am reading a long text file with currently round about 900.000 lines (log files). I am then filling a DataTable object with the data and until then everything is fine. But when assigning the huge DataTable object to the DataGridView.DataSource it takes ~ 10 minutes until the application is responsive again and the DataGridView shows the data. The same happens if I load the data to the DataGridView directly without a DataTable object. Is there a better way to work with this huge amount of data and a DataGridView?
Yes; you need to enable "virtual mode". This isn't entirely trivial, as you need to provide the code to provide cell values on-demand (rather than filling everything in advance), but it isn't horrendous either. Here's a complete walkthrough in the Microsoft docs.
However, from a UX perspective, maybe a better solution is to make it such that you don't need to display nearly a million lines in a grid. That isn't a useful user experience, in most cases.

Biniding data from dataset to gridview taking time

I am having one windows form which is dynamic form,used in many forms.
In this form i have to bind data from dataset to datagridview.But takes 3-4 minutes to bind data from dataset to datagridview.Result from query executed is placed in dataset.And then this dataset is then bind to datagridview as
dgSearch.DataSource=ds.tables[0];
but this statement takes time to execute.As my dataset has more than 100k rows. How to bind such large amount of data to datagridview?
I have a C# windows application.
First, the idea of binding that much data in an application suggests either a) bad architecture or b) bad business requirements. People cannot process 100,000 rows at one time. If this is a report, then the grid is not your best way of handling this.
If you are forced to head this direction, I would consider some form of paging and only show a portion of the "gridded" data at any one time. http://www.codeproject.com/Articles/16303/DataGrid-Paging-C-Windows-Forms
Heading this direction, you can control the amount of data that is bound at any one time. You can also implement sort on different columns so the user can refine what he or she is looking at. But you will dramatically speed up binding, as you are not binding 100K+ rows at a time.
If you have large amount of records, the best way to show the records is that you have paging in your gridview.
Effective paging is important for applications that handle large number of records to build scalable applications.
Here is the good article for that. It shows you how to do it on ASP.NET web forms, but when you find out the way of that you can do it on windows forms application.
Also there is another question may help you with that. What is the fastest way to load a big data set into a GridView? It's for windows forms application. You may read this too for solving your problem.
Hope it helps.

DevExpress Winforms XtraGrid and SQLite bound database, best way to insert rows?

I have successfully bound a SQLite database table to a DevExpress XtraGrid control, and can see the few test rows I have, and can also edit the values, and commit the changes back to the database with an Update command upon closing.
My question is what would be the best way for me to insert rows to the table? I have implemented and successfully used some example code for inserting rows into a SQLite table, however I am uncertain if the DevExpress XtraGrid has some type of method to allow me to skip all of the example code I have, and simply use the same functionality that seems to be already built into the control.
So should I use example code that connects to the database, builds the query then runs it on the database, or is there a better way, using something already built into the DevExpress WinForms suite?
Thanks.
You can use Embedded Navigator controls to insert rows !
https://www.devexpress.com/Support/Center/Question/Details/Q235790
After some research, I found that the best way to interact with the data in the grid, or with any database for that matter, is to use DevExpress's eXpress Persistent Objects for .NET. Great bit of technology. It allowed me to specify the database and table I was interested in, and it created all of the plumbing to allow me to deal with rows in the table like normal C# objects with properties.
If you are struggling with trying to mix in SQL queries and the like into your application, I highly recommend you make your life much easier and use XPO.
Here is a link to the documentation describing XPO: http://documentation.devexpress.com/#XPO/CustomDocument1998

C# GUI, have to display a huge table and make it sortable

I am making a small C# GUI application that reads table-like (cells, rows, columns) data from a binary file and displays it to the end user. Some files are very small (5 columns / 10 rows), but some are very big (245 columns and almost 50,000 rows).
The one and only method I found to easily display a MsExcel-like table was DataGridView. I was really happy with it when I tried the small files, but as soon as I tried with the huge one it went OOM before it even finished loading (and I had more than 4 GB of free memory).
After that though I found out its VirtualMode, and it was really fast. However unfortunately columns were no longer sortable and that is a must.
So, what can I do to obtain performance similar to DataGridView's virtual mode but have it sortable as well? (If you have another control in mind it's okay, I don't have to necessarily use DataGridView)
Also, please note that:
The binary files were not designed or produced by me. I have no control over their format.
The data is not in a database.
My end users shouldn't have to install a database and import the data there.
You can handle the sorting by yourself and sort the datasource of datagridview with one of the "standard" sorting algorithm.
If you use List, you can use a "Sort()" method. However every collection can by sorted by yourself.
Look for some third party contols. I've used Janus (www.janusys.com) and DevExpress (www.devexpress.com) for grids and they work great.

Categories