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

CellStyleInfo.Tag null in row header cell?

Thread ID:

Created:

Updated:

Platform:

Replies:

10309 Jan 29,2004 05:17 AM UTC Jan 29,2004 07:53 AM UTC Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On January 29, 2004 05:17 AM UTC

Hi, I''ve set the .Tag property on a bound column to a custom object, I can get this object back in the cell click event, but only on non header cells. For a header cell, the .Tag value is null. Is this something to do with sorting? I''m using a GridDataBoundGrid. Is there a way of not losing the .Tag value? Cheers, Ed

Administrator [Syncfusion]
Replied On January 29, 2004 07:53 AM UTC

Yes, the sorting support in GridDataBoundGrid uses the Tag object to track what column is sorted and how it was sorted. As a work around, you could create a hashtable to hold your tag objects for the header row. You could use the column mapping name as the key. You can store this hashtable as the Tag in cell 0,0 which is unaffected by the sorting support. Then when you need the tags, access them though cell 0,0. Here are some snippets. //set up the hashtable Hashtable ht = new Hashtable(); for(int i = 1; i < this.grid.Model.ColCount; i++) { //save some object for each column with mapping name key //here we just store the original colindex string key = this.grid.Binder.InternalColumns[i-1].MappingName; object o = i; ht.Add(key, o); } // store the hashtable as the Tag in cell 0,0 this.grid[0,0].Tag = ht; //use the hashtable private void grid_CellClick(object sender, GridCellClickEventArgs e) { if(e.RowIndex == 0 && e.ColIndex > 0) { Hashtable ht = this.grid[0,0].Tag as Hashtable; if(ht != null) { int fieldNum = this.grid.Binder.ColIndexToField(e.ColIndex); string s = this.grid.Binder.InternalColumns[fieldNum].MappingName; object o = ht[s]; if(o != null) { Console.WriteLine("column header {0} clicked", o); } } } }

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

;