User (Old forums)MemberSeptember 19, 2007 at 9:32 amPost count: 23064
In our Project,after displaying the data grid using tableview, We are in need to access the Data cells for some validation purpose.
How is it possible ? Please explain this with some code.
Imported from legacy forums. Posted by Britto (had 1229 views)Xceed SupportMemberSeptember 19, 2007 at 2:44 pmPost count: 5658
You can access a DataCell in the following manner:
Xceed.Wpf.DataGrid.DataRow row = this.MyGrid.GetContainerFromItem( this.MyGrid.CurrentItem ) as Xceed.Wpf.DataGrid.DataRow;
row.Cells[ 0 ]…..
Keep in mind that only the containers for data items that are in the viewport are realized; therefore, it is possible that you get null when using the GetContainerFromItem if the data item is not in the viewport.
Imported from legacy forums. Posted by Jenny [Xceed] (had 2950 views)User (Old forums)MemberAugust 11, 2008 at 5:07 amPost count: 23064
Is there a possibility to get the displayed value of a Cell instead of the index if the cell is templated with a ComboBox?
I tried two ways:
– via DataRow (System.Data):
DataRow row1 = dataGridControl.Items as DataRow;
– via Xceed Row:
Xceed.Wpf.DataGrid.DataRow row2 = dataGridControl.GetContainerFromItem(dataGridControl.Items) as Xceed.Wpf.DataGrid.DataRow;
//Xceed.Wpf.DataGrid.DataRow row2 = dataGridControl.Items as Xceed.Wpf.DataGrid.DataRow;
The second variant worked only for displayed rows. I really don’t get the sense of Xceed Row and Xceed DataRow, displaying only visible rows in viewport. But that’s not the point:
Does anybody know a way to display this?
Imported from legacy forums. Posted by Matt Kay (had 908 views)User (Old forums)MemberAugust 19, 2008 at 2:09 amPost count: 23064
Can anybody help me, or even tell me if it’s possible or not, please?
Imported from legacy forums. Posted by Matt Kay (had 598 views)Xceed SupportMemberAugust 19, 2008 at 8:11 amPost count: 5658
Xceed.Wpf.DataGrid.DataRows are containers that are created only of the data items that are displayed in the viewport; therefore, you will not be able to access the Cells in the Xceed DataRows in the way you would like. In this case, your best option would be to go through the data source and access the System.Data rows instead.
That said, these values will represent the IDs and not the displayed values. I suggest you take a look at the ID/Value mapping example in my documentation download folder:
These examples demonstrate how to display a value rather than an ID in a combobox and should help you get the value from the ID as well.
Imported from legacy forums. Posted by Jenny [Xceed] (had 464 views)User (Old forums)MemberAugust 25, 2008 at 7:48 pmPost count: 23064
If I may make a suggestion regarding post #9569…You may wish to make it a sticky with a title of “How to access data in the current row.” Just use the few lines of code that are in the post. The other method I found in the posts doesn’t work with the WPF grid.
Imported from legacy forums. Posted by Jon (had 510 views)User (Old forums)MemberSeptember 4, 2008 at 7:54 amPost count: 23064
I have an additional question:
How do I get access to DataRow which is not in the ViewPort respectively how to bring it into ViewPort?
This one doesn’t work for a row [i] which is not in the viewport. tmp is always null:
DataRow tmp = dgc.GetContainerFromItem(Items[i]) as DataRow;
Imported from legacy forums. Posted by Matt Kay (had 725 views)Xceed SupportMemberSeptember 4, 2008 at 9:04 amPost count: 5658
Calling BringIntoIntoView before calling GetContainerFromItem should work. Are you getting any errors?
Imported from legacy forums. Posted by Jenny [Xceed] (had 409 views)User (Old forums)MemberSeptember 4, 2008 at 9:45 amPost count: 23064
Unfortunately it doesn’t work. Something weird: BringItemIntoView return true so::
true if the specified element was brought into view; false otherwise.
But if it reallly would be in the ViewPort it wouldn’t be null….
Apart from the Exception that tmp is null I don’t get any errors.
What’s really funny: if I don’t try to access the container (call the GetContaionerFromItem method), then the viewport changes.
When the error occurs, as I mentiones, it doesn’t.
PS: Could the fact play a role, that the DataGridControl is embedded in other Controls?
Imported from legacy forums. Posted by Matt Kay (had 561 views)User (Old forums)MemberSeptember 8, 2008 at 2:55 amPost count: 23064
I found the missing thing here:
I have to call UpdateLayout() after BringItemIntoView and then I may call the GetContainerFromItem().
Imported from legacy forums. Posted by Matt Kay (had 846 views)User (Old forums)MemberOctober 3, 2008 at 4:38 amPost count: 23064
Thanks for adding that here, it helpmed me a lot.
Dear Xceed Team,
You may want to update the documentation of BringItemIntoView() method with the inforamtion related to UpdateLayout().
Imported from legacy forums. Posted by Koti (had 1693 views)
- You must be logged in to reply to this topic.