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.

Store object for the cell

Thread ID:

Created:

Updated:

Platform:

Replies:

51843 Nov 15,2006 01:05 AM Nov 16,2006 01:50 AM Windows Forms 5
loading
Tags: GridControl
Sandeep
Asked On November 15, 2006 01:05 AM


Hi,

I want to store some background value (say object of class) to every cell in the databoundgrid. Is there any way to do it? I tried with control and tag properties but they are showing null after adding it and checking in any other event.

Thanks,
Sandeep

Administrator [Syncfusion]
Replied On November 15, 2006 01:34 AM

Hi Sandeep,

If you want to set a GridStyleInfo.Tag property on a cell specific basis in a DataBoundGrid, then you have to handle Model.QueryCellStyleInfo and set e.style.Tag based on the values passed in through the event arguments.

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/GDBGTag_270c4675.zip

Best Regards,
Haneef

Sandeep
Replied On November 15, 2006 03:47 AM


Hi Haneef,
QueryCellStyleInfo will get execute at the time of binding. Its OK. But now I want to add the object for the cell at some other position like after clicking the button I want to add background object to particular cell by using its rowindex and colindex. So what exactly I would require to do for it.

Thanks,
Sandeep

Administrator [Syncfusion]
Replied On November 15, 2006 05:22 AM

Hi Sandeep,

In QueryCellStyleInfo, you should have some collection (or something) that holds the object that you assign to e.Style.Tag. When you want to modify the Tag, you need to set the object value in this collection (or something) with RowIndex and ColIndex as the Key. Please refer to the attached sample for implementation and let us know if you are looking something different.

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/GDBGTaghash_87e4997c.zip

Best Regards,
Haneef

Sandeep
Replied On November 16, 2006 01:12 AM


Hi Haneef,

Thanks for your sample.
But I want little different thing.

I have dropped the idea of storing the object at the back of the cell. I want now to store only one particular string at the back of cell (front text of cell will be different.). I dont want to use the event like QueryCellStyleInfo which require Hashtable or any other collection as a middle.
Is there any way to do store string at back of cell at particular position. Please let me know if it is possible.

Thanks,
Sandeep

Administrator [Syncfusion]
Replied On November 16, 2006 01:50 AM

Hi Sandeep,

It is not possible to store the cell style properties other than handling the events(Model.QueryCellInfo) for a DataBoundGrid. If you want to change the display text of the cells in a grid, you can handle the DrawCellDisplayText event and set the e.DisplayText to some new value to want to display. Use the e.Style.CellIdentity.RowIndex and e.Style.CellIdentity.ColIndex to get the row and column of the cell for which the displaytext has to be set. Below is a code snippet.

private void DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
if(e.Style.CellIdentity.ColIndex == 1 && e.Style.CellIdentity.RowIndex > 0 && e.DisplayText != null && e.DisplayText != string.Empty )
{
e.DisplayText = "JustForDisplay" ;
}
}

Best Regards,
Haneef

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.

;