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.
Unfortunately, activation email could not send to your email. Please try again.

FAQ 5.67

Thread ID:

Created:

Updated:

Platform:

Replies:

2153 Dec 18,2002 11:57 AM Dec 20,2002 08:49 AM Windows Forms 2
loading
Tags: FAQ
ying
Asked On December 18, 2002 11:57 AM

5.67 give out the current row of a datagrid, did any one know how to get the current index of the underlying table after the datagrid is sort? Thanks

Administrator [Syncfusion]
Replied On December 20, 2002 08:49 AM

I had the same problem once.. Now I made a class to deal with it.. it only works if the table has a primary key!!! the idea is : 1) get a reference to that row that you are interested in. 2) make a copy(and not by Ref),(with Table.Copy()) of the table. make sure that you apply two this second table the same filter and sort like for the first one.(because Copy() doesn’t do this.) 3) now in one table , delete the row that you are interested in, leaving the other intact.. (having a ref row it easier to delete ;(myRow.Delete()), you can do it with an RowFilter like :Table.DefaultView.RowFilter="NOT ((name="Paul") AND (...).. ) ").actually hiding the row.. 4)Compare the two tables to see from where at the same index the rows are not equal. This is very simple and fast , since you can make something like Binary Search: First compare table in the middle . if they are equal then your row is in the second part Then take the second part and compare in the middle again… …. For a table with 28 000 lines this finds the row in less then 16 comparations. It’s fast!!! If you don’t want to create another table(space problems..), you can this only with the original table.(save the middle row in a variable, delete your row, compare now your row with the middle row ……), but is much slower.. Any way.. I’ll send the class that I made. I needed it for an auto complete algorithm, so it’s main function finds a row by a word (exact or nearest ) from a specific column. Public Functions: 1)Find(). Finds the table row index from( a ref DataRow, a ref DataRowView or by a value from a column ) 2)FindRow() :Finds a DataRow, DataRowView from a value of a column 3) BinarySearch (): known BinarySearch… needs previous sort.(when return positive values –there is a match, when returns negative values- this is the index of the closest bigger value) sorry that I didn’t put an example also… sorry that it isn't complete yet..it steel has some problems.. for comments or suggestions:DanielZaharia_y@Yahoo.com > 5.67 give out the current row of a datagrid, did any one know how to get the current index of the underlying table after the datagrid is sort? > > Thanks

Administrator [Syncfusion]
Replied On December 20, 2002 08:49 AM

I had the same problem once.. Now I made a class to deal with it.. it only works if the table has a primary key!!! the idea is : 1) get a reference to that row that you are interested in. 2) make a copy(and not by Ref),(with Table.Copy()) of the table. make sure that you apply two this second table the same filter and sort like for the first one.(because Copy() doesn’t do this.) 3) now in one table , delete the row that you are interested in, leaving the other intact.. (having a ref row it easier to delete ;(myRow.Delete()), you can do it with an RowFilter like :Table.DefaultView.RowFilter="NOT ((name="Paul") AND (...).. ) ").actually hiding the row.. 4)Compare the two tables to see from where at the same index the rows are not equal. This is very simple and fast , since you can make something like Binary Search: First compare table in the middle . if they are equal then your row is in the second part Then take the second part and compare in the middle again… …. For a table with 28 000 lines this finds the row in less then 16 comparations. It’s fast!!! If you don’t want to create another table(space problems..), you can this only with the original table.(save the middle row in a variable, delete your row, compare now your row with the middle row ……), but is much slower.. Any way.. I’ll send the class that I made. I needed it for an auto complete algorithm, so it’s main function finds a row by a word (exact or nearest ) from a specific column. Public Functions: 1)Find(). Finds the table row index from( a ref DataRow, a ref DataRowView or by a value from a column ) 2)FindRow() :Finds a DataRow, DataRowView from a value of a column 3) BinarySearch (): known BinarySearch… needs previous sort.(when return positive values –there is a match, when returns negative values- this is the index of the closest bigger value) sorry that I didn’t put an example also… sorry that it isn't complete yet..it steel has some problems.. for comments or suggestions:DanielZaharia_y@Yahoo.com > 5.67 give out the current row of a datagrid, did any one know how to get the current index of the underlying table after the datagrid is sort? > > Thanks

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;