XtraGrid & DataNavigator control issue - winforms

I'm have a GridControl with 12 Records and I am using the DataNavigator control for navigation between the records.
When I click on any record within the gridview(for example 3-rd record) the DataNavigator showing something like: Records 7 of 12
Looks like it displaying random values, formatted with the TextStringFormat.

This behavior is reproducible when using the DataNavigator control belong with the GridControl, and data are sorted on any column other than key column. This behavior is correct because the DataNavigator control is bound to a data View or data Table. The DataNavigator control is not directly bound to a control which displays this data.
Please replace the DataNavigator control with the ControlNavigator control. The ControlNavigator.NavigatableControl property must be set to your GridControl. In this case, the navigator will move focus according to the order of rows in the XtraGrid.
Or use the Embedded Navigator feature of GridControl.
You can read more about these approaches in the following help article: Using Navigators

Related

enable/disable data grid columns using ivalue convertor in silverlight

I am working on a silverlight application using MVVM. My requirements is to display existing user data in data grid so that first two columns remains non-editable and rest will be editable.
At start datagrid loads data from database, at that point if user click on data grid first two columns should be non-editable.
After that user insert a new row (i create a button, when that is clicked a new row is added at the bottom of the grid) all columns should be editable including first two. Now user can click Add row buttons more than once, point is rows created by Add button click should be editable.
I am stuck at this problem since yesterday any help would be great!
I dont know Silverlight but I think the following should work:
On your command to add a new row, set a flag like "AllRowsEditable" to true and throw a PropertyChanged for this Property. In your view you bind the IsReadonly property of the first two columns to that "AllRowsEditable" property.
EDIT: Write a ViewModel for your DataGrid items. For example "RowViewModel". To have a good structure I would introduce two properties like "IsFirstPropertyReadOnly" and "IsSecondPropertyReadOnly" in that ViewModel. "...firstProperty..." is your properties name. In your XAML you can bind to this properties. In your first initialization you load the items and set the property values to true. All items added after that you set that properties to false.

DataGridTemplateColumn Binding Using a TextBox in WPF with MVVM

I have a DataGrid that is bound to a List (ListOne). Inside the grid I'd like to display an extra TextBox that contains fields found in another Class that is not the same as the Class used in ListOne.
I've done this before with a ComboBox using the DataGridTemplateColumn, the problem is I'm not sure how the Binding would work when using a TextBox?
ListOne contains code and description which is bound and displays correctly. My SQL Stored Procedure returns extra values using a Join, which I'd like to display as editable fields ListOne.
Any ideas?
You should probably try to bind the DataGrid directly to the joined data as i imagine that doing joins directly in the cells may be difficult and round-about.

WPF input datagrid?

I would like to create an input DataGrid - an empty set of rows with the column headers that can be filled with data by a user and then saved to a database. The DataGrid will not be therefore used to display data but acts like an input field. The behaviour would be similar to the one of Excell. The problem is that if the DataGrid has no data provided for it, it is not visible in the application and the user cannot enter anything. Is the DataGrid a good choice? How can this sort of functionality be implemented with a different control? I would prefer to use the DataGrid tough.
Thanks a lot for any help on this.
You can enter data in a DataGrid even without provided data at the start of the application. You just need the correct bindings for your ItemsSource, and set CanUserAddRows to true. Also, the class that corresponds to a row of a DataGrid must implement a parameterless constructor.

Winforms: Best control to use for listing data quickly

I need a control that can list data in 3 columns, I want to manually add the items (not databind the control).....
firstly I'll populate column 1 and 2, then later when a button is clicked, I need to loop through the values of column 1 and 2, perform an operation, then update the value of column 3.
From what I remember the datagrid does not allow for this , and must be bound to a data source, am I right?
What is the best quick drag and drop control I can use from the toolbox?
Use a ListView with View property set to Details. Then you can add columns to the listview.
From what I remember the datagrid does
not allow for this , and must be bound
to a data source, am I right?
This is not right. The DataGrid can be used in bound or unbound mode. If you don't bind it, you can just add rows and columns and populate cell contents as you need. You could choose to do this if you wish. It will solve your problem.
But I think it would be simpler for you to create a custom class to represent a row and use the DataGrid in bound mode. You can refresh the binding when you click the button.

WPF DataGrid - Setting RowDetails programmatically

I'm using the WPF DataGrid, and I'd like to know if there is any way I can access the DataGridRow's RowDetails programatically.
For example, when the user selects the row, I'd to grab some data from somewhere (say, a database), and display it in the RowDetails.
All of the examples I've seen tend to just display some extra bound data that isn't included in the columns for the row.
You could display some extra data but lazy-load it on SelectionChanged.
It usually is not easy to work directly with the WPF controls, they are not really meant to be used without a backing databound model.
If you have all the data in list of objects (or something similar) then you can do all sorts of fun things. I'm using a WPF Datagrid in this manner, and when a user selects a row, I think populate an editor control above the grid with the row item plus additional details.
That said, there's nothing stopping you from adding in additional information in the grid that's normally hidden and a trigger on row selection to show the additional data
you can use the following code
DataRowView row = (DataRowView)MyDataGrid.SelectedItem;
string strName = row.Row["Name"].ToString(); //where "Name" is the column name

Resources