Nested Data Tables: They said it can not be done? - c#

I have been trying unsuccessfully to do something that I would have thought in WPF should be quite easy.
We wanted to display a table in a cell of another table recursively (that can be expanded / collapsed). (Not Master / Detail, but true tree like recursion into the sub-tables)
We thought maybe a DataGrid or a GridView might be able to achive this but we've been unsucessful in our attempts, so I wanted to check with the world at large that we're trying to do something possible.
If it helps, it's readonly data, but it's all data-driven so there's a dynamic number of rows and columns.

Look into the DataGrid's RowDetailsTemplate. You should be able to add whatever you want in there including another Grid.

You need a hierarchical data grid, evaluate Infragistics

Related

Customize Data Grid View in Windows Form

Like this
how can I customize datagridview to be like this photo in like
which means its start with full empty rows, like in accounting programs
Firstly, I would not recommend that you do this. Most good accounting programs don't do it either!
That said, the first way to do it would be to create a suitable set of data with the required number of rows already in it and then assign that as the data source. If you go beyone the available list then add a new row to the datasource.
The second way to do it would be to subclass DataGridView and handle the drawing yourself to draw the grid to mimic the rows.
I cannot recommend either option, and would recommend simply allowing new rows to be automatically added as the user enters something in the 'new' row. This is the way that most good programs do it.

WPF MVVM Creating rows and columns during runtime

I create application, where user creates alternatives and criteria. My alternative should have list of criteria, so user can give value for particular criteria in alternative. I would like to present this as a matrix, where rows are alternatives and columns are criteria. User during runtime can create new alternatives and criteria. Both are created using dialogbox, additionally presented in ListView. I store them in ObservableCollection.
My problem is, that DataGrid control doesn't offer easy way to add columns. I look for a solution to my problem, where I could create during runtime both columns and rows. Maybe DataGrid is wrong control to use in this scenario. I found some solution, but it doesn't feel right to me. All data, that user inserts, will be later used in solver. Maybe DataTable is way to go?
example: https://svitla.com/blog/grid-with-dynamic-number-of-rows-and-columns-part-1

WPF window that looks like excel

I am new to WPF and c#, and I am trying trying to create an excel like table with a fixed number of columns and a varying number of rows according to the user's needs.People advise to use a datagrid, but I am very confused, some say that it is used mostly to display data source content (which is data contained in database if I understood). I read also about listviews, binding things to itemsource...etc. This is really a lot of information to work with! What I simply need is a way to create a table with fixed columns, and adding rows automatically when the user clicks on a button, that's it! No binding, or anything of this sort.But how to achieve that? Also, if you have good websites tutorials for working with datagrids, I would be very grateful (most of those that I found are too much complex, or don't explain well).
Thanks a lot!
You can create datatemplates that will style your data to look however you like - in this case an Excel row. Then you can display this data as the ItemsSource in an items control. Since you want the number of rows to vary based on some criteria, your data should be in an ObservableCollection. I'm not sure how you'd set-up the header, but I think you could style-up some containers and bind their width properties to the datatemplate controls.
If you wish to do more cell level customizations, then you can try Grid
http://www.syncfusion.com/products/user-interface-edition/wpf/grid/grid-control

Alphanumeric Sort Datagrid - Reusable Worry Free Code

Friends,
I have about 20-30 datagrids that have different data on all of them. Is there a way that I can sort a datagrid with out writing custom code in each sorting event?
I want some code that all i need to do is pass it in a name of a datagrid, and perhaps a direction.
I don't want to make a call back to the database, but instead, i have a List Each Datagrid will have a different Generics List Value.
Bill.
Yes, use LinqDataSource on all of them and paging and sorting will be taken care of for you without writing a single line of code.

Gridview and Column sets

I have a Gridview that is data bound to an array of objects, with a ton of properties attached to them. The grid would need to be too wide to show all of them at once (and also overwhelming for the user), so I'd like to have some link buttons that post back to the server and show different sets of columns (all from this same data set array of objects), based on what "tab" the user clicked.
In the GridView I use TemplateFields to bind the columns to the object properties. What would be the best way to implement the different columns and views?
Should I just bind all the data, and then on the post back event for a tab press, show and hide only the columns I need for that tab? This seems like since it would be binding a lot more data than I am showing, that it might be unnecessarily slow.
Should I dynamically create the columns before the binding, and only create the columns and bind the data for the columns I want to show? What is the performance hit the page would take for dynamically creating the columns each time based on which tab was pressed?
Thanks!
If you have that many columns, you may want to think about using a different control instead of a gridview. A DetailsView with paging would probably render better and be more manageable for the users.
To answer your question, though, I don't believe option 1 would be that much of a performance hit. And I believe that option would be less strenuous than option 2. That mostly my opinion, though.

Categories