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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid Cell bound to multiple DataTables

Thread ID:

Created:

Updated:

Platform:

Replies:

18141 Aug 24,2004 06:09 PM UTC Aug 24,2004 07:20 PM UTC WinForms 3
loading
Tags: GridControl
Madhavi Balusu
Asked On August 24, 2004 06:09 PM UTC

Hi, I have a usercontrol that I am showing in a column of my grid. The user controls displays information from 2 tables. The usercontrol and the gridcell seem to be exchnaging values via CellValue. The question is: 1)For the table cell, how do I distinguish between the 2tables. i.e. if I set a CellValue=2, how can I distinguish which table that cell is referring to? Thanks!

Administrator [Syncfusion]
Replied On August 24, 2004 06:20 PM UTC

Are you setting gridBoundColumn.StyleInfo.CellType = "Control" for the column. If so, this will not work. With th e"Control" celltype, you cannot use the cell control in more than one cell. The reason is that there is no way to for the single control to handle values from multiple cells. To share a cell control among several cells, you have to derive a CellModel class and a CellRenderer class. You can see samples in the grid\samples\celltypes\monthcalendar and in the cellttype\slider samples that we ship. (There are also many other samples that use derived cell controls. Do a search for CellModels.Add in the grid\samples folder to see them all.) If this is not what you need, can you explain a little more about what you are doing?

Madhavi Balusu
Replied On August 24, 2004 06:38 PM UTC

Hi Clay, I am deriving from CellModel and CellRenderer. This is what I have right now: this.expenseGrid.Model.CellModels.Add("MyCtlModel", new MyCtlModel(this.expenseGrid.Model)); this.colService.StyleInfo.CellType = "MyCtlModel"; MyCtlModel instantiates my usercontrol. This usercontrol show data from 2 tables. Imagine I want to set my grid''s style.CellValue=2 from the usercontrol, but this ''2'' is the value from 2nd table and not 1st. How do I let the grid''s cell know that? That it has to display the DisplayMember of the 2nd table and not 1st? Thanks!

Administrator [Syncfusion]
Replied On August 24, 2004 07:20 PM UTC

If you want to assign the value 2 to the grid at the cell which is active from within the renderer class, you can try this.Grid.Model[this.RowIndex, this.ColIndex].CellValue = 2;. The grid would not care whether the value 2 came from one table or the other. Normally, you override renderer.OnSaveChanges to save the value from the control in the renderer to the Grid. Here is what the GridCellRendererBase.OnSaveChanges looks like.
protected virtual bool OnSaveChanges()
{
	TraceUtil.TraceCurrentMethodInfoIf(Switches.CellRenderer.TraceVerbose, this.ControlText);
	if (CurrentCell.IsModified)
	{
		Grid.Model[currentRowIndex, currentColIndex].FormattedText = this.ControlText;
		return true;
	}
	return false;
}

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

;