Create an empty chart for user to input data - c#

What is the best way to create an empty chart (like a spreadsheet) so that the user can fill the cells with some data (strings, numbers)? The number of rows and columns is not known, it's determined at runtime. The data given by the user should then be easily loaded to, say, 2D array. Is using DataGrid a good solution?

You might want to check
RadSpreadSheet
Infragistic WPF SpreadSheet
DevExpress Spreadsheet
SynFunction Spreadsheet
These are third party control and not free.
This one is open source control.
Creating your own is of course lots of work and you may want to refer to these for a starter.
If you want to make a simple editable DataGrid follow this link.
Also look at IEditableCollectionView
IEditableCollectionView is a new collection view that you can use to supports adding and removing new items, as well as editing items in a transactional way. It is implemented by ListCollectionView (the default view for ObservableCollection) and BindingListCollectionView (the default view for DataTable). I will go through an example to further describe it and summarize afterwards.

Related

Creating binding source vs just assigning a List<C> for combobox?

In the following link, the author shows how to create a binding source and add sorting function to a grid view. It should work similarly for combobox datasource. However does it have any benefit to do it for simpler controls like combobox or listbox? I can just assign a list of type List<AClass> and then assign the DisplayMember and Value for the controls.
http://aviadezra.blogspot.com/2008/06/binding-domain-objects-in-visual-studio.html
Even for data grid view, does it work well for complex situation like, for example, sorting on a grid view with paging? Looks the class PropertyComparerCollection in the example only works the loaded data.
The article is focused on binding complex business objects to the grid view. This has been a intensively debated subject since .Net Framework 2.0. If the properties of your bound type are no longer primitive, then you have to get your hands dirty to support sorting, filtering or searching.
There are plenty generic classes for this goal, but I would recommend this implementation, with a nice video demo here.
However, if you're not aiming at a data grid view, but rather at a combo box or list box, and wish not to modify the underlying store while sorting or filtering, you could still use a custom class derived from IBindingListView and BindingList(of T), like the one suggested above and manually call ApplySort or ApplyFilter. The implementation in the article linked in your post and the one I suggested use temporary copies of the original data source for sorting/filtering.
Furthermore, for paging instead of taking slices out of the original data source, you'd be taking slices out of the wrapped sortable view of that data source.

Create a dynamic grid depending on my data source with mvvm

Do you know if this is possible and if so how to do it?
I have a set of data which will be created at runtime in my view model. Now I want to present these data to the user in a grid which automatically creates columns and rows depending on the number of data items in my data source.
When the window is created it should not generate it all over again - just let it be static as I think that is easiest.
my data source is a class containing a filepath, file name and an image.
Is it possible?
Yes it is possible. You can use Microsoft DataGrid. It has a lot of feature that can be helpful (automatic columns generation, virtualization, columns sorting and reordering...)
Alternatively, you can use a simple ItemsControl and set its ItemsPanel as a Grid, and then implement a custom logic to generate Rows/Columns when ItemsSource changes.

Delphi equivalent of C#'s DataGridView

Is there any real equivalent of C#'s DataGridView in Delphi?
I have tried
TStringGrid
But the scrollbar is either invisible when all the items are visible, or it is the smallest scrollbar possible no matter how little the items are overflowed and only updates when the scrollbar is released, not when it is being dragged
Also, if you have one fixed row, you have to have at least one (empty) row besides that, which is inconvenient and unsightly
TDBGrid
But I can't seem to figure out how to add items programmatically (and I don't think it's meant to do that anyway). If I could do that, TDBGrid would be fine for me to use.
So what is the Delphi equivalent of C#'s DataGridView that doesn't have the problems listed above?
The DataGridView is a very flexible control which can work in bound and unbound modes, in the Delphi side you must choose bewteen 2 kinds of controls, for example if the content of the control can be edited directly (unbound) you can choose a component like a TStringGrid or in bound mode which in delphi is called data-aware you must choose something like a dbgrid, in this last case you edit the dataset asociated to the control and the control reflect the content of the dataset. Using this last scenario. you have several options about the dataset component to choose maybe the most flexible is the TClientDataSet. if you want learn more about this topic check these links
Understanding datasets Index
Types of Datasets
Opening and Closing Datasets
Modifying Data
Note : in the last version of Delphi (XE2) a new concept was introduced called LiveBindings, which introduces big changes in how you can bind a object or component to a collection or another component.
I would recommend you to check DevExpress.com QuantumGrid - it works both in Bound and Unvound mode

How do I display a DataGridView within a cell of another datagridview in C# forms app?

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

UI for creating invoices

Currently, I'm in the process of making a custom solution for invoicing. I have created multiple ways for customers to create their template (HTML, Word, LaTex) and get invoices according to their template. However, these invoices are party manually generated.
So, the process is:
Request to create a new invoice
An preliminary invoice is created
The user gets a chance to make changes (i.e. add, remove, change rows)
Create a pdf
Just to be clear, the preliminary invoice does not need to be formatted as the template is, but you should be able to add/remove/change rows and for every cell, indicate whether the value should be visible in the final result.
My problem is that i cannot find a suitable way to display the preliminary invoices. I tried a datagrid (default, telerik, devexpress), but it's too messy. Besides a datagrid, i have no idea what i can use.
What controls can i use best to have a nice and usable UI.
Please don't be like this:
alt text http://bitsandpieces.us/wp-content/uploads/2008/03/imagesapple-20google-20and-20you.png
A typical UI paradigm for this kind of thing is to view it as two separate problems: giving the user a way of viewing the elements that he can modify, and giving him the ability to modify any specific element. You use a list control (ListBox, ListView, maybe TreeView if the elements are organized hierarchically or need to be grouped into categories) to present the elements, and then when the user selects an element the program presents a tabular presentation of field names and editable value controls.
Basically, you're dividing the program's functionality into two categories: stuff that the user wants to do to rows (add, remove, re-order, select) and stuff that the user wants to do to the selected row's elements.
You can mush these two sets of functionality into one if you use a DataGridView, but as you've seen that gets pretty ugly if there's any complexity to the elements you're editing.
Two possible approaches to this: the property-sheet paradigm (select object, right-click, select "Properties", edit values in a modal dialog), or a paradigm where the window's split into two panels, with one being the rows and the other being the details of the currently selected row. There are lots of others.
What is your platform? Winforms? WPF?
What exactly did you dislike about using a datagrid for this? Part of the problem is that whether you like it or not, you're going to be coding a datagrid - you essentially described features of one. If at all possible try to use someone else's datagrid because it will save you a lot of work. Typically, 3rd party datagrids should be fairly customizable, and you should be able to make it look however you want - and take advantage of the built in sorting, editing, grouping, etc. Creating a datagrid-like control from scratch isn't easy and should be avoided if possible.
You don't have to have a plain giant datagrid - you can crate a custom control that displays the invoice formatted however you like, with a live datagrid appearing only where the invoice shows tabular data, formatted to appear as an integral part of the invoice itself.
I'm doing something similar, where the client can edit or even remove the line items for the invoice prior to sending it to the client.
The current app they run their business on is a WebForms Intranet application, so this is an extension to that. So they can add/remove/edit rows fairly easily.
But Egor is right. You're essentially talking about a datagrid no matter what you do. I take it you want something 'cleaner' and more intuitive?
Simplicity is difficult.
I would take a look at what is already out there, especially for invoices, and see how they are doing it.
Not sure how big your company is, but it never hurts to take advantage of the large company applications and user interfaces, the pour thousands/millions of dollars into user interface design and testing.
I would take a look at any of the following (most offer a free trial, or just try searching for screenshots):
www.freshbooks.com
www.invoicera.com
www.getcashboard.com
www.simplifythis.com
Just some ideas ... hope this helps!

Categories

Resources