Skip to main content Skip to footer

Olap Grid: Customizations using C1FlexGrid Part I

OLAP Controls are made up of best of C1Controls combined together, thus everything that is possible with individual controls, is also to some extent possible with constituent controls within OLAP for Winforms, albeit with some minor tweaking here and there. As the title suggests we are going to talk about customizing OlapGrid in this blog, and how to customize it vis-a-vis C1FlexGrid control. Once we place any Olap control on a Form (Windows), references to C1FlexGrid, C1Chart and C1PDF are automatically added to the project and there is a good reason for it, without these references we would not be able to access all that the individual controls have to offer, otherwise. Beginning with a very simple example, in this post, I will show how to customize Grid styles for the OLAPGrid control. For this we need one standard C1OLAP control, one Access datasource, C1Nwind in our case, and some backend coding, styling preferences as per individual taste. ;) Directions to follow:

  • Create a new Windows application ,
  • Drop a C1OlapPage control on the form,
  • Set the project Data source as the C1NWind mdb file

The next is highly personalized choice but incase you want the OlapGrid to be populated as soon as the form is loaded, add the following code to the Form_Load event,

c1OlapPage1.OlapEngine.RowFields.Add("CategoryID", "ProductName");  

What will this do? Instead of asking the user to fill the Row and Column fields this would make sure the application opens up with some data populated for the user to see. To make things organized lets drop a button on the form, and put the following code in its click event,

//Create a new Cell style and add it to existing grid styles  
CellStyle cs1 = c1OlapPage1.OlapGrid.Styles.Add("Test1");  
//Set Style elements  
cs1.BackColor = Color.LightBlue;  
cs1.ForeColor = Color.Black;  
cs1.Font = new Font(FontFamily.GenericSerif, 9, FontStyle.Italic);  
cs1.Border.Style  = BorderStyleEnum.Double;  
//Apply style to specific cells  
c1OlapPage1.OlapGrid.Cols[1].Style = cs1;

The above code, as is evident, creates a new style, applies the cell attributes, and sets it to a particular column of the OlapGrid Control. Clicking on this button when the application is running would create an effect similar to as shown in the image below, For an easy reference, all the above has been implemented and attached with the following sample as well. Download Sample


comments powered by Disqus