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

Keep hightlight does not work?

Thread ID:

Created:

Updated:

Platform:

Replies:

29163 May 18,2005 12:20 PM UTC May 18,2005 02:22 PM UTC WinForms 1
loading
Tags: GridControl
david bosak
Asked On May 18, 2005 12:20 PM UTC

Hi, I have the keep hightlight as the following to sort: private void KeepHighLightAfterSorting(MyGridDataBoundGrid grid, object sender, GridCellClickEventArgs e, int lastRowBeforeSorting, string pKey) { int row, col; try { pKey = pKey.Replace(" ", "_"); grid.PointToRowCol(new Point(e.MouseEventArgs.X, e.MouseEventArgs.Y), out row, out col, -1); if(row == 0 && col > 0) { //Save the current position CurrencyManager cm = (CurrencyManager) this.BindingContext[grid.DataSource, grid.DataMember]; PropertyDescriptorCollection pdc = cm.GetItemProperties(); // Find a primary string pkCol = string.Empty; string fields = this.adhocParamsVO.PagingFields; if (fields.ToUpper().IndexOf("SSN") > -1) { pkCol = "SSN"; } else if (fields.ToUpper().IndexOf("AIN") > -1) { pkCol = "AIN"; } else { pkCol = this.adhocParamsVO.PagingHeaders.Split('','')[0]; } PropertyDescriptor pd = pdc.Find(pkCol, true); int colIndex = grid.Binder.NameToColIndex(pkCol); object val = grid[lastRowBeforeSorting, colIndex].Text; //primary key value on teh current row //Do the sort, assumes datasource is a DataTable DataTable dt = (DataTable) grid.DataSource; DataView dv = dt.DefaultView; string colName = pKey; ListSortDirection sd = ListSortDirection.Ascending; if(grid[row, col].Tag != null) { sd = (ListSortDirection)grid[row, col].Tag; } string sdString = (sd == ListSortDirection.Ascending) ? "Desc" : "Asc"; dv.Sort = string.Format("{0} {1}", colName, sdString); if (dtMain.Rows.Count > 0 && this.adhocParamsVO.HasBreakOrTotal) { this.dtMain.DefaultView.Sort = ""; this.dtMain.DefaultView.Sort = dv.Sort.ToString(); grid.DataSource = this.TotalBreakColumn(dtMain.DefaultView); FormatColumns(fieldInfoList); grid.Refresh(); } //Do what you want to do after the sort, restore the current position //restore current object grid.MySelectionMode = SelectionMode.MultiExtended; int rowIndex = (cm.List as IBindingList).Find(pd, val) + 1; colIndex = grid.CurrentCell.ColIndex + 1; grid.CurrentCell.MoveTo(rowIndex, colIndex); grid.Refresh(); // grid.ScrollCellInView(rowIndex, colIndex); } } catch (Exception ex1) { if (lastRow < 1) { lastRow = 1; } grid.CurrentCell.MoveTo(lastRow, 1); // rowZero = false; // this.NavigatorButton_Click(null, null); if (log.LogError()) { log.Error(ex1.Message); } } } Before running this method, I hightlighted row 10. However, after run this method, a colum is hightlighted instead row 10. Please help!

Administrator [Syncfusion]
Replied On May 18, 2005 02:22 PM UTC

Where are you doing this code? Is it from a CellClick event? Using this code in a CellClick event worked ok for me in 3.2.1.0.
private void gridDataBoundGrid1_CellClick(object sender, GridCellClickEventArgs e)
{
	if(e.RowIndex == 0)
	{
		this.gridDataBoundGrid1.ListBoxSelectionMode = SelectionMode.MultiExtended;
		this.gridDataBoundGrid1.CurrentCell.MoveTo(3,3);
	}
}

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.

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

;