We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

IsSynchronizedWithCurrentItem

Hi ,

Good Day .

How to get 'IsSynchronizedWithCurrentItem' in SfDataGrid ?

Thank you .

Regards,
Yap

1 Reply

EM Elavarasan M Syncfusion Team May 14, 2015 04:12 AM UTC

Hi yapwen,


Thank you for using Syncfusion products.


We analysed your query and currently we don’t have direct support for IsSynchronizedWithCurrentItem in SfDataGrid. You can achieve your requirement (to use IsSynchronizedCurrentItem) in sample level. We have prepared a sample by using IsSynchronizedCurrentItem in SfDataGrid. Please find the sample from the following location:
Sample: http://www.syncfusion.com/downloads/support/forum/119125/SfDataGridSample63424717.zip

In the above sample, we have loaded SfDataGrid and ComboBox with same itemssource. By using current changed event in view of the datagrid, selected item of a grid will be reflected in combobox. For this, you need to change the current item of the collection (which is bound to the SfDataGrid and ComboBox) by using MoveCurrentTo method in Collectionview as shown in the following code snippet:


Code Snippet:

this.datagrid.View.CurrentChanged += View_CurrentChanged;


void View_CurrentChanged(object sender, EventArgs e)

{

//while selecting item in a grid, setting current item of collection (which is bound to the SfDataGrid and ComboBox) as current item of sfdatagrid.

CollectionViewSource.GetDefaultView(this.datagrid.View.SourceCollection).MoveCurrentTo(this.datagrid.CurrentItem);

}



While selecting an item in combobox, it will be reflected in datagrid with the help of currentchanged event of the collection (which is bound to the datagrid and ComboBox) and current item of datagrid is set as the current item of the collection in the event as shown in the following code snippet:
Code snippet:

CollectionViewSource.GetDefaultView(this.datagrid.View.SourceCollection).CurrentChanged += MainWindow_CurrentChanged;


void MainWindow_CurrentChanged(object sender, EventArgs e)

{

//while selecting item in combobox, setting current item of sfdatagrid from the current item of collection.

if ((sender as ListCollectionView).CurrentItem != datagrid.CurrentItem)

datagrid.CurrentItem = (sender as ListCollectionView).CurrentItem;

}


Please refer the below UG link to know about CurrentItem in Sfdatagrid:


UG Link: http://help.syncfusion.com/ug/wpf/index.html#!Documents/selection1.htm

Please let us know if this solution helps you.
Thanks,
Elavarasan M


Loader.
Live Chat Icon For mobile
Up arrow icon