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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Model_SelectionChanged

Thread ID:

Created:

Updated:

Platform:

Replies:

6017 Jul 29,2003 05:20 AM UTC Jul 30,2003 08:00 AM UTC WinForms 7
loading
Tags: GridControl
Cradle
Asked On July 29, 2003 05:20 AM UTC

private void Model_SelectionChanged(object sender, Syncfusion.Windows.Forms.Grid.GridSelectionChangedEventArgs e) { How can I get the selectedrow's value???? I want Load another grid's value according to this grid's selected row! }

Administrator [Syncfusion]
Replied On July 29, 2003 05:55 AM UTC

> private void Model_SelectionChanged(object sender, Syncfusion.Windows.Forms.Grid.GridSelectionChangedEventArgs e) > { > How can I get the selectedrow's value???? > I want Load another grid's value according to this grid's selected row! > } >
GridRangeInfoList ranges = this.grid.Selections.GetSelectedRows(true, false);
foreach(GridRangeInfo range in ranges)
{
	for(int i = range.Top; i <= range.Bottom; ++i)
	{
		string value_Col1 = grid[i, 1].Text;
		Console.WriteLine(string.Format("Row {0} selected - value in col1: {1}", i, value_Col1));
	}
}	

Administrator [Syncfusion]
Replied On July 29, 2003 06:01 AM UTC

The above code lets you get all the selected rows. If by selected row, you mean the row with the currentcell, then you can get its row number with code like: int row = this.grid.CurrentCell.RowIndex; If you are using a ListBoxSelectionMode = One, then you can get the row with code like: int row = this.grid.Selections.GetSelectedRows(true, false).ActiveRange.Top;

Cradle
Replied On July 29, 2003 06:21 AM UTC

private void Model_SelectionChanged(object sender, Syncfusion.Windows.Forms.Grid.GridSelectionChangedEventArgs e) { MessageBox.Show(this.gridDataBoundGridM.CurrentCell.RowIndex.ToString()); gridDataBoundGridM.Allowselection property os set to "row" but MessageBox will run 2 times,I only want to got selected rowIndex(just like Master-Detail table,select one row in Master,then according selected row to load another grid)! Thanks a lot

Administrator [Syncfusion]
Replied On July 29, 2003 07:29 AM UTC

This event is called once when the old selection changes to 'nothing', and then is called again when the new selection changes to 'something'. You can check e.Range.IsEmpty to see which case it is.

Cradle
Replied On July 30, 2003 06:33 AM UTC

Thanks,but another Q: When I Change to another Grid Row(new row), old select row can not Lost foucus(focus just on a cell of old row),so CurentRowIndex is Old Row Index. I click new row again,CurentRowIndex is new Row index. How can i get new row Index using selectChaged event ? what's more, How can I get this CurentRow's Binding data? Thanks a lot!!!

Administrator [Syncfusion]
Replied On July 30, 2003 07:56 AM UTC

If you are interested in catching when you change rows (as opposed to changing selections which is different), then you should try the CurrentCellMoving (before the fact), or the CurrentCellMoved events. In these events you can get the to and from rows from properties of the CurrentCell object, grid.CurrentCell.MoveToRowIndex and grid.CurrentCell.MoveFromIndex. Selections normally are not necessarily related to moving the currentcell. So, if you are really interest in catch the current cell moving, you do not want to rely on SelectionsChanged. Given any row in the grid, you can get the item from the DataSource through the CurrencyManager. CurrencyManager cm = (CurrencyManager) this.BindingContext[this.gridDataBoundGrid1.DataSource, this.gridDataBoundGrid1.DataMember]; int pos = this.grid.Binder.RowIndexToPosition(gridRowIndex); DataRowView drv = (DataRowView)cm.List[pos];

Cradle
Replied On July 30, 2003 08:00 AM UTC

Thanks a Lot!

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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon

;