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

How to associate data w/cell w/out using Tags?

Thread ID:

Created:

Updated:

Platform:

Replies:

28610 May 5,2005 01:36 PM UTC May 5,2005 05:21 PM UTC Windows Forms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On May 5, 2005 01:36 PM UTC

Hi. I have a grid which displays an expandable/collapsible tree in both the first and second columns. Each cell in those two columns has a custom cell model. The custom cell model has a cell button and needs to know: - if the button bitmap is a plus or minus - how much to indent the cell button and text - if the cell is a leaf-node and has no button In order to facilitate this, I want to associate two values with each cell in those first two "tree" columns. - bool hasChildren - bool treeLevel In the past, I have done this by getting a reference to the underlying row data (an instance of a backing store class) for the row in question. But this couples the tree-grid implementation too closely to the underlying data. I''ve tried using custom events (QueryTreeNodeInfo) which fire when the grid is painting a tree-cell. This got a little ugly because the user of the tree-grid has to register an event-handler with the cell-renderer (which is where the drawing takes place). So the user has to dig into the guts of the grid control to get at the runtime cell model instance for the given cell. Instead, I''d like to somehow associate the hasChildren and level values with the cell directly. Perhaps as part of the StyleInfo for the cell? What are my options here? What can/should I subclass in order to associate these two properties with cells of the custom cell model? Thanks, Andy

Administrator [Syncfusion]
Replied On May 5, 2005 01:39 PM UTC

Oops. Although I said it in the subject line, I should re-emphasize that I do not want to use the cell Tag to solve the problem. The reason is that I''m creating a derived grid control that knows how to manage tree columns. I want users of the derived grid control to be able to use the cell Tags w/out interfering with the internal operation of the trees.

Administrator [Syncfusion]
Replied On May 5, 2005 02:36 PM UTC

You can extend GridStyleInfo to hold your own custom properties. For example, the style.MaskEdit, style.CurrencyEdit and style.FormulaTag are extended properties added to the GridStyleInfo class. So, if you have the grid source code, you could take one of these (the FormulaTag may be closest to what you have), and create your own extended style property mimicing that code. Here is a link to a sample showing this process which might be simpler. http://www.syncfusion.com/support/user/uploads/customstylepropertiessample.zip

Administrator [Syncfusion]
Replied On May 5, 2005 04:03 PM UTC

Clay, Thanks for the sample. I have been looking through it (seemed easier than wading through the grid source-code). I''ve also been looking through the grid documentation. I can see how to create a custom properties derived class. But I''m not clear on how I get a particular cell to make use of the derived class. I can see in the Usage() method how to create a custom property class instance. But still, that doesn''t tell me how the instance is "registered" with the grid control for the specific cells. I''m sure it''s in the sample code somewhere, but I''m not understanding it yet. Andy

Administrator [Syncfusion]
Replied On May 5, 2005 05:21 PM UTC

For example, you can add a button and button handler to the sample form. At the end of the form''s constructor, you can set these properties on cell 1,1 using: GridStyleInfo style = gridControl1[1,1]; style.Text = "SomeText"; MyCustomStyleProperties customStyle = new MyCustomStyleProperties(style); customStyle.TheLocked = true; customStyle.TheFont.Bold = true; Then you can retrieve these properties in the buttonhandler using this code. The code also flips their values, so the next time you click the button, you see a different result.
private void button1_Click(object sender, System.EventArgs e)
{
	MyCustomStyleProperties customStyle = new MyCustomStyleProperties(this.gridControl1[1,1]);

	Console.WriteLine("{0}  {1}", customStyle.TheLocked, customStyle.TheFont.Bold);
	customStyle.TheLocked = !customStyle.TheLocked;
	customStyle.TheFont.Bold = !customStyle.TheFont.Bold;
	Console.WriteLine("");
}

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

;