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.
Syncfusion Feedback

GridGroupingControl - SourceListRecordChanged event

Thread ID:

Created:

Updated:

Platform:

Replies:

46657 Jul 18,2006 10:49 AM UTC Jul 24,2006 11:14 AM UTC Windows Forms 8
loading
Tags: GridControl
Clive Hill
Asked On July 18, 2006 10:49 AM UTC

I think a previous post about the below has been lost, so re-posting... I need to get a reference to the GridStyleInfo of a cell when it''s underlying value has changed in the DataSource. If I can get this reference I can set the cell blinking when an update occurs. If I use event SourceListRecordChanged, I can get a reference to the Record that has changed, but from here there doesn''t seem to be a way to get a reference to the changed cell''s GridStyleInfo. I''ve had a look at Sample Windows\Grid.Grouping.Windows\Samples\RealtimeUpdates, but this uses 4.2, while I have 4.1, which doesn''t have a definition for GroupingTable used there. Also, it doesn''t show explicitly how to get hold of GridStyleInfo as it uses PaintElement method with a Graphics object. This must be a common requirement... Can someone let me know how to achieve blinking on cells updated from their underlying DataSource?

Administrator [Syncfusion]
Replied On July 18, 2006 11:49 AM UTC

Hi Vito, The QueryCellStyleInfo event has to be handled to set the style property for the cells. It is not possible to set the style for the cell directly, because GridGroupingControl is row/column oriented and not cell oriented. Please refer to the attached sample, that demonstrates the way you could color the changed cells in the grid by handling the QueryCellStyleInfo. Here is a sample http://www.syncfusion.com/Support/user/uploads/GGC_Color_5a0d8046.zip Let me know if you need any further assistance. Regards, Rajagopal

Clive Hill
Replied On July 18, 2006 01:47 PM UTC

The problem with the approach given is that RecordValueChanged occurs when the user updates the grid. I need to know when the underlying datasource is updated from externally. SourceListRecordChanged can be used to tell when the DataSource is updated externally, but the code that is in the sample for RecordChanged can''t be used, as the CurrentCell is not set to the cell that has been updated from externally. As GGC.TableControl.CurrentCell can''t be used, is there another way to get a handle on the "currently updating via underlying data source" cell? (i.e. not updated by the user?)

Administrator [Syncfusion]
Replied On July 18, 2006 04:29 PM UTC

Here is a try at doing this that will probably work if your datasource is a datatable. http://www.syncfusion.com/Support/user/uploads/GGC_ButtonImage_44c6f6f4.zip It uses SourceListRecordChanged like you suggested to get the record being changed and uses the DataTableColumnChanging event to catch the column being changed. It looks the record up in the DisplayElements to get its row index in teh grid and maps the column name to the field to get the column index.

Clive Hill
Replied On July 18, 2006 05:30 PM UTC

Fantastic! That works. I assume that you mean to take the gridRow and gridCol values and put into GGC.TableControl.GetTableViewStyleInfo to get reference to GridTableCellStyleInfo of the cell back. If that''s the case then I needed to pass in (gridcol-1) to get correct reference. Thanks!

Clive Hill
Replied On July 19, 2006 09:06 PM UTC

Ok. I assumed once I had a reference to the GridTableCellStyleInfoEventArgs within QueryCellStyleInfo event blinking the background color would be trivial. But it seems as though when the e.Style.BackColor is updated in a seperate Thread the value is not updated.

Attached, is a class called in this if statement within QueryCellStyleInfo handler:

if (e.TableCellIdentity.Column != null && List.Contains(new Cell(e.TableCellIdentity.DisplayElement, e.TableCellIdentity.Column.Name)))

If I set the back color immediately in the contructor of the class the cells change to red, however within the Timer Tick event no change occurs. Is there a wat around this?

(Btw, I realise that this won''t blink, I''ll set to alternate color once I am sure the background color is updated. Also, this is simplified version of what I intend to implement, as I''ll probably have a collection of cells that need to be blinked and add/remove to this collection as necessary.)

BlinkingCellHelper.zip

Administrator [Syncfusion]
Replied On July 19, 2006 10:44 PM UTC

Here is the sample back with the changed cells being colored.
http://www.syncfusion.com/Support/user/uploads/GGC_ButtonImage_81d8e371.zip

Just setting e.style.backColor in some timer loop is not suffiect. What you need to do is to tell the appropriate cell to redraw itself in your timer loop, and then in QueryCellStyleInfo, set the e.style.BackColor.


Clive Hill
Replied On July 21, 2006 03:19 PM UTC

Thanks Clay. I''ve got blinking working now for multiple columns. One thing I didn''t realise is that in QueryCellStyleInfo the background doesn''t retain its previous color, but is set to White.

Last issue is if the user clicks on the column and changes its position, the previous coulmns location gts updated. I assume same will happen with rows. This is because where I handle the Tick and do RefreshRange, the row and col indices are found from SourceListRecordChanged. I guess I in addition need to check the Visible Columns name''s and get their positions. Is there an easy way to handle this mapping?

Administrator [Syncfusion]
Replied On July 24, 2006 11:14 AM UTC

Hi,

Use the column name as the Key instead of the colindex. Here is a sample that works fine, in coloring the changed cells when column''s position is changed.
GGC_ButtonImage1.zip

Thanks,
Rajagopal

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

;