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

Column format with contextmenu

Hi,

we are using a GGC to display our data. The control is bound to a dataset object. Now I have implemented a context menu which shows up when a user clicks on a column header. The context menu offers the user to change the column format. So if we have a column full of double values - he can change the format string with something like this:

GridTableDescriptor childTD = test.TableControl.TableDescriptor;
GridTableCellStyleInfo myStyle = childTD.Columns[test.ColumnIndex].Appearance.AnyRecordFieldCell;
myStyle.Format = "##.00000000";

This works fine. Though we have also columns which contains string values, and therefore I don''t wann show that context menu with the format option. Cause it doesn''t make sense to set the "myStyle.Format" string for a string value. My question is now, how can I find out if the underlying data is of kind numeric or of kind string (to enable or disable the format option in my context menu). I didn''t find out how to get the data type of the underlying data of a column. Hope somebody understands my question :-)

Kind regards
Tim

2 Replies

AD Administrator Syncfusion Team July 26, 2006 12:32 PM UTC

Hi Tim,

Please try handling the MouseUp event of the TableControl, there you can check for the cellvaluetype(datatype) of the column like in the code below.


// TableControl_MouseUp event
GridTableDescriptor td = this.gridGroupingControl1.TableDescriptor;
Point pt = new Point(e.X, e.Y);
GridTableCellStyleInfo style =this.gridGroupingControl1.TableControl.PointToTableCellStyle( pt );
if(td.Columns[style.TableCellIdentity.Column.Name].Appearance.AnyRecordFieldCell.CellValueType == typeof(string))
{
/// code to enable/disable menu item in contextmenu ////
}


Here is a rough sample, that demonstrates, the way you could show only certain menu items based on the data type of the column.
GGC_ContextMenu.zip

Let me know if you need any further assistance.
Regards,
Rajagopal



AD Administrator Syncfusion Team July 26, 2006 12:59 PM UTC

You are great - this works just fine for me. Besides - your response time is really great - keep it up guys :-)

Loader.
Live Chat Icon For mobile
Up arrow icon