Populating listview row into an array or list - arrays

Is it possible to enter listview data by row instead of by cell? I would like to be able to pull data out of the listview by row using an index rather than having to create a ton of statements to pull out the data by cell, it would be easier this way.

Related

How to save the changes made in the NSTableView back to the source array used for the populating this table?

I have view based NSTableView with two columns. Instead of default NSTextFields I have inserted NSTextViews. For populating the table I am using the array of tuples of two strings. After I change the text in the NSTextViews I want to save back all changes from all rows and columns to the source array by clicking the button. I need to know each row and NSTextViews to get the strings for the array. How to do this ? First problem is that I cannot even make the tags for particular NSTextViews, they are inactive in Attributes Inspector (for NSTextFields tags are active).

ShieldUI Grid row count

In ShieldUI (1.7.13) Grid
How can I have a row count beside each record in a grid?
This is not data from the JSON which provides the other data for the Grid.
Situation, I am scrolling a list of hundreds of records and want to provide the consumer of the data the row number of the various rows in the grid.
Similar to the row number in any popular spreadsheet application (Excel, Google Sheets, etc.)
You can add a new column as the first one, specifying a custom columnTemplate for it. In there you can show the current index of each row.
More information is available here:
https://www.shieldui.com/documentation/grid/javascript/api/settings/columns/columnTemplate

Column Names in DataGrid

I have a datagrid say Grid1 and I have a datatable called Dt in the codebehind where the column names and data will be changing always. I am giving the itemssource as shown below
Grid1.ItemsSource=Dt.DefaultView;
In this case if I dont have any rows in the datatable but it just has column names but still I need to show up the column names in the datagrid.
The way the DataGrid works is to infer the automatic columns from the row data itself. If there are no rows, it doesn't generate any columns!
You can work around this problem by simply adding an empty row when the table does not have any rows:
if (Dt.Rows.Count == 0)
Dt.Rows.Add(Dt.NewRow());
Grid1.ItemsSource = Dt.DefaultView;
If you don't want to modify the original table you can create a copy first with DataTable.Copy.

Inserting rows into pagedcollectionview, while preserving the location

I have to create a grid which allows sorting and filtering. Currently I am able to achive this by binding PagedCollectionView of the data. I would like allow user to insert or delete row from the grid with context menu. User can select a row and right click on the context menu and insert or delete a row. I can delete the current row, but adding row got me stumped. When I insert a new row and since I do not know any values, I insert a blank row and that end up coming at the end of the grid.
One solution I am working on is to copy the previous row of the gird and using converter, if the row is dirty display blank.
Just curious, is there a better way of inserting row at current place in a grid while keeping sorting and filtering in place?
Thanks,
Just in case anyone is interested, what I ended up doing is insert the row in the grid manually with out paged collection view to keep the sorting and in the code behind insert a dummy row.

How can one dynamically modify row and column definitions of a WPF grid?

I have two dimensional data with varying number of rows and columns and must display it to the user for editing. The format of the data itself is essentially described by a list of row and column descriptors with a header text for each row or column.
I derived a control from Grid that has two properties for the row and column descriptors and builds the gird rows and columns based on that information. It also subscribes list change events of the two descriptor collection to update itself if the user dynamically adds or removes rows or columns.
And here the problem occurs - when I try to modify the row or column definitions of the gird I get an exception telling that the collection is read-only. So I assume it is not possible to modify the definition after the grid has been created and shown once. Any ideas?
And just in the case it matters - everything is data bound. There is a (dynamic) collection of tables with each table containing its own (dynamic) row and column definitions and the data entered for each cell.
I did a quick test and I could add rows and columns without problems to a Grid at runtime through code, using the RowDefinitions and ColumnDefinitions collections. I don't think that bindings have something to do with the problem either.
If on the other hand you meant DataGrid, yes, that changes things quite a bit.

Resources