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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

CellStyleInfo.Tag null in row header cell?

Thread ID:





10309 Jan 29,2004 05:17 AM UTC Jan 29,2004 07:53 AM UTC WinForms 1
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); } } } }


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon