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

Calculated DataColumns in DataBoundGrid + Events Handling in DataBoundGrid & GroupBoundGrid

Thread ID:





26324 Mar 21,2005 01:11 PM UTC Mar 25,2005 03:14 PM UTC WinForms 6
Tags: GridControl
Prof DISSOU Jamâl-Dine
Asked On March 21, 2005 01:11 PM UTC

Please any help will be helpfull on : 1. how to do a compute of sum of a particular column in a DataColumns in DataBoundGrid 2. how to use calculated datacolumns in a DataColumns in DataBoundGrid 3. how to sum the fields in a DataColumns in DataBoundGrid and display the calculated totals in a footer 4. how to Handle events that there are raised when an cell in DataBoundGrid (or GroupBoundGrid) is changed 5. how to handle or implement MS Access like events in DataBoundGrid (or GroupBoundGrid) : 5a - AfterInsert : raised after insert a new row or new record in a DataBoundGrid (or GroupBoundGrid) 5b - AfterUpdate : raised after update a row or record in a DataBoundGrid (or GroupBoundGrid) 5c - BeforeInsert : raised before insert a new row or new record in a DataBoundGrid (or GroupBoundGrid) 5d - BeforeUpdate : raised before update a row or record in a DataBoundGrid (or GroupBoundGrid) 5e- OnCurrent : raised when the focus move to another row or record in a DataBoundGrid (or GroupBoundGrid) 5f - OnDelete : raised on deletion of a row or record in a DataBoundGrid (or GroupBoundGrid) 5g - OnNotInList : raised when a item is not found in ComboBox in a DataBoundGrid (or GroupBoundGrid) 6. how to Handle events that there are raised when an ComboBoxCellColumn in DataBoundGrid (or GroupBoundGrid) is changed With best regards, Jamal-Dine DISSOU

Administrator [Syncfusion]
Replied On March 21, 2005 05:44 PM UTC

1 & 3) If you need this type of functionality, you may be better off using a GridGroupinControl where it is supported instead of a GridDataBoundGrid where you have to code it yourself. If you want to do it in a GridDataBoundGrid, here is a KB. http://www.syncfusion.com/Support/article.aspx?id=10398 2) You add a DataColumn to the DataTable that is the DataSource for the GridDataBoundGrid, and set the DataColumn.Expression property. Again, this is something supported directly in GridGroupingControl but not in GridDataBoundGrid. 4) I am not sure what you are asking. Do you want to know the the actual events? If so, for a GridDataBoundGrid, CurrrentCellChanged is raised with every change in a cell. (This means with every key troke if your user is typing.) CurrentCellValidating is raised when your user leaves the cell. You can cancel this action by setting e.Cancel after testing grid.CurrentCell.Renderer.ControlText to see if it is something you want to allow. Here is a little snippet that checks for a double in particular column in a GridDataBoundGrid.
private void gridDataBoundGrid2_CurrentCellValidating(object sender, CancelEventArgs e)
	GridCurrentCell cc = this.gridDataBoundGrid2.CurrentCell;
	if(cc.ColIndex == 7)
		string newValue = cc.Renderer.ControlText;
			double d = double.Parse(newValue);
			cc.ErrorMessage = "Not a double...";
			e.Cancel = true;
In a GridDataBoundGrid, changes are cached on a row by row basis, and are only pushed to the datasource when the user leaves the row. There are events asociated with these actions as well, RowLeave, RowSaved, RowEditing and RowEnter. For a GroupingGridControl, the CurrentRecordContextChange event is raised at several points during the current cell activating editing process. You can check e.Action in this event to get the context. You also have access to the TableControlCurrentCellChanged and TableControlCurrentCellValidating events (like GridDataBoundGrid). Here is a forum thread with some info on this event. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=22307 5) In a GridDataBoundGrid, you can use the grid.Binder.BindingListChanged to get at the ListChanged event on the datasource. You can check the ListChangeType to see that different actions that are caught by this event. Normally, ILists only raised a ListChanged event which is after the action and not prior to the action. SO, I do not know of a good way to get the actions handled in ListChanged before thay actually take place in the DataSource in general. If youwant to catch actions from changes within the grid itself (not actions done by some other datasource user outside the grid), you can use the row events mentioned above. In a GridGroupingControl, there are SourceListRecordChanging and SourceListRecordChanged events. You can check the e.Action to see what action is taking place. Here is a little sample showing these vents. http://www.syncfusion.com/Support/user/uploads/GGC_ChangeEvents_727fbb1.zip 6) The TableControlCurrentCellChanged event in GridGroupingControl and the CurrentCellChanged event in GridDataBoundGrid should be raised with a change to a combobox cell.

Prof DISSOU Jamâl-Dine
Replied On March 22, 2005 12:45 PM UTC

Thanks Jamal-Dine DISSOU

Prof DISSOU Jamâl-Dine
Replied On March 24, 2005 05:30 PM UTC

Hi Clay, I have an additional inquiry. How to do a compute of column in a DataColumns in DataBoundGrid (or GroupBoundGrid) and display the calculated totals in a TextBox on the form With best regards, Jamal-Dine DISSOU

Administrator [Syncfusion]
Replied On March 24, 2005 06:39 PM UTC

If you do not care about seeing the totals in the grids, you can just work directly with teh datasource and handle things there in a manner that would work with either grid. You culd listen to the DataTable.ColumnsChanging event to dynamically show the totals. Here is a little sample. http://www.syncfusion.com/Support/user/uploads/GDBG_LabelSum_bc8b14a9.zip

Prof DISSOU Jamâl-Dine
Replied On March 25, 2005 12:00 PM UTC

Hi Clay, Thank you for your prompt answer. I hope you don''t wonder I have more questions. 1.How to do string concatenation in Expression Column in GGC. e.g : "Sync" + "fusion" = "Syncfusion. 2. How to manually add Column to a GGC (ComboBoxColum, CheckBoxColumn, Currency, MaskEdit, MonthCalendar, GridListControl, .....) 3. How to apply special StyleFormat to a Coulumn in a GGC 4. How to set Column HeaderText, Width, ReadOnly property of a Column in a GGC Best regards, Jamâl-Dine DISSOU

Administrator [Syncfusion]
Replied On March 25, 2005 03:14 PM UTC

1) In, there is no support for this using Expression columns. (In the upcoming 3.2, there is a mechanisn for you to add custom fuctions that you can define for use in Expression columns, and you could use that to support appending strings.) But there is another way to do this that would work in both 3010 and 3.2. It is to add an unbound column by using the TableDescriptor.UnboundFields collection. Then in the QueryValue event for your unbound field, you can provide whatever value you want for the cell, appending strings or whatever. Take a look at this sample. It shows how to add a unbound field. Syncfusion\Essential Suite\\Windows\Grid.Windows\Samples\Grouping\EmployeeTerritoryOrder 2) Do you mean an unbound column? If so, see the sample listed above. Once you have added an unbound column, you can use it like any other column. In particular, you can set any of its style properties using the columns Appearance object. this.gridGroupingControl1.TableDescriptor.UnboundFields.Add("boolCol"); this.gridGroupingControl1.TableDescriptor.Columns["boolCol"].Appearance.AnyRecordFieldCell.BackColor = Color.Red; this.gridGroupingControl1.QueryValue += new FieldValueEventHandler(gridGroupingControl1_QueryValue); To specify the column''s cell type like a combobox or checkbox, you would set the CellType property on the appearance object. this.gridGroupingControl1.TableDescriptor.Columns["Col"].Appearance.AnyRecordFieldCell.CellType = "ComboBox"; this.gridGroupingControl1.TableDescriptor.Columns["Col"].Appearance.AnyRecordFieldCell.DataSource = someDataTable; this.gridGroupingControl1.TableDescriptor.Columns["Col"].Appearance.AnyRecordFieldCell.DisplayMember = "someCol"; this.gridGroupingControl1.TableDescriptor.Columns["Col"].Appearance.AnyRecordFieldCell.ValueMember = "someCol"; 3) You set TableDescriptor.Columns["Col"].Appearance.Format. To have the format be applied properly, you also have to make sure TableDescriptor.Columns["Col"].Appearance.AnyRecordFieldCell.CellvalueType is set properly, otherwise teh format is ignored. 4) You can set these properties on this.gridGroupingControl1.TableDescriptor.Columns["someCol"].


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