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.

Cell click event handler

Thread ID:

Created:

Updated:

Platform:

Replies:

1496 Nov 5,2002 01:51 AM Nov 6,2002 12:51 AM Windows Forms 1
loading
Tags: GridControl
Cyrille Claustre
Asked On November 5, 2002 01:51 AM

I have a problem with the events while cliking in a cell. I use the first cell of a row to apply an action to all the selected cells in this row. I use something like this (C# code) : SuspendChangeEvents(); if ( col == 0 && row == 4 && Selections.Ranges.Count > 0 ) { BeginUpdate(); SortedList toDelete = new SortedList(); for ( int i = 0; i < Selections.Ranges.Count; i++ ) { GridRangeInfo range = Selections.Ranges[i]; for ( int j = range.Left; j <= range.Right; j++ ){ toDelete.Add( j, j );}} for ( int i = 1; i <= toDelete.Count; i++ ){ int j = (int)toDelete.GetByIndex( toDelete.Count - i ); DeleteSequence( j ); // some personal stuff GridRangeInfo range = GridRangeInfo.Cols( j - 1, j - 1 ); Selections.Remove( range ); if ( ColumnDeleted != null ){ // Fire personal event TableEventArgs args = new TableEventArgs( j, ws ); ColumnDeleted( this, args );}} Selections.Clear(); EndUpdate( true ); Refresh(); ResumeChangeEvents(); First, I have to set the CellValue property for the cell I clicked each time the handler is called, or else the text simply dissapears (not mentionned in the sample code above). Moreover, sometimes after calling this handler, the next click anywhere on the grid will reenter the handler. I just don't know why. Is this due to the events I fire from the handler method ? I can't figure what happens. Hope my explacations will be clear ;o) Thank you.

Administrator [Syncfusion]
Replied On November 6, 2002 12:51 AM

> I have a problem with the events while cliking in a cell. I use the first cell of a row to apply an action to all the selected cells in this row. > > I use something like this (C# code) : > > SuspendChangeEvents(); > if ( col == 0 && row == 4 && Selections.Ranges.Count > 0 ) { > BeginUpdate(); > SortedList toDelete = new SortedList(); > for ( int i = 0; i < Selections.Ranges.Count; i++ ) { > GridRangeInfo range = Selections.Ranges[i]; > for ( int j = range.Left; j <= range.Right; j++ ){ > toDelete.Add( j, j );}} > > for ( int i = 1; i <= toDelete.Count; i++ ){ > int j = (int)toDelete.GetByIndex( toDelete.Count - i ); > DeleteSequence( j ); // some personal stuff > GridRangeInfo range = GridRangeInfo.Cols( j - 1, j - 1 ); > Selections.Remove( range ); > if ( ColumnDeleted != null ){ > // Fire personal event > TableEventArgs args = new TableEventArgs( j, ws ); > ColumnDeleted( this, args );}} > Selections.Clear(); > EndUpdate( true ); > Refresh(); > ResumeChangeEvents(); > > First, I have to set the CellValue property for the cell I clicked each time the handler is called, or else the text simply dissapears (not mentionned in the sample code above). > Moreover, sometimes after calling this handler, the next click anywhere on the grid will reenter the handler. I just don't know why. Is this due to the events I fire from the handler method ? I can't figure what happens. > Hope my explacations will be clear ;o) > Thank you. The default behavior is for a cell to begin editing when you click on it. This is controlled on a grid-wide basis by the grid's ActivateCurrentCellBehavior property. So, when you click, the cell goes in the edit mode, and the passes the focus to the control determined by the CellType of that cell, probably a TextBox unless you have set it to something else. I suspect the problems are coming about becuase of this active cell. If you do not want your user's to edit this column, you could try setting the CellType to Static (from the default TextBox) to see if that would avoid this behavior. Another thing you could try is to call CurrentCell.EndEdit() at the start of your code to see if that would take care of the problem.

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.

;