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.

Button cell in databound grid

Thread ID:





26783 Mar 31,2005 09:05 AM Mar 31,2005 09:10 AM Windows Forms 1
Tags: GridControl
Administrator [Syncfusion]
Asked On March 31, 2005 09:05 AM

I am using a button cell in a databound grid to select a record using the event "PushButtonClick" The code I am using works fine when the grid is loaded, however when sorting using one of the headers and clicking the button it retrieves the wrong record. Code is below gdbgGrid.CurrentCell.MoveTo(e.RowIndex, e.ColIndex); dt = (DataTable)gdbgGrid.DataSource; DNoteID = (Guid)dt.Rows[e.RowIndex-1]["DNoteID"]; How can I get the correct index from the grid when it is sorted. Thanks Aaron

Administrator [Syncfusion]
Replied On March 31, 2005 09:10 AM

You need to use the CurrencyManager to access the data if it can possibly be sorted. int pos = grid.Binder.RowIndexToPosition(e.RowIndex); CurrencyManager cm = (CurrencyManager) grid.BindingContext[grid.DataSource, grid.DataMember]; DataRowView drv = (DataRowView)cm.List[pos]; //DataRow dr = drv.Row; MessageBox.Show(string.Format("{0} {1}", drv["1"], drv["2"]));


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.