Home > .Net, C# > Janus GridEx customizable cell content

Janus GridEx customizable cell content

Recently i had accomplished interesting task, which include to add time duration data to one of the existing Grids in our Winform desktop application. We are working with 3rdParty controls Janus (Janus.Windowa.GridEx).

Unfortunately not all our controls are WPF, so we still need to “struggle” WinForms to make any special changes in UI.

The problem was that our product manager wanted to make usage of the same visual column for different types of data – such as >int and System.TimeSpan. As you can see they have completely different presentation.
After some thinking we have decided to add additional column of Type Syste.TimeSpan and make this column hidden to the end user.

MyColumns = m_gridControl.RootTable.Columns;
MyColumns["durationColumnName"].Visible = false;

Useful feature that Janus GridEx gives us is to draw cell content by ourselvs, just sign to the following event and you can do whatever you want (getting Graphics).
Another example that shows the power of this approach is to implement progress bar inside of single cell.

m_gridControl.DrawGridArea += new DrawGridAreaEventHandler(OnGridControlDrawGridArea);
//Next step is to set following property to Cells
MyColumns["durationColumnName"].OwnerDrawnMode = ColumnOwnerDrawnMode.Cells; // Indicates what kind of event arg you will get

private void OnGridControlDrawGridArea(object sender, DrawGridAreaEventArgs e)
    if(e.Column.Key = "DurationColumName")
        GridEXCellCollection currentRowCells = e.Row.Cells;
        // Draw default back groud as all other cells
         , e.Font
         , new SolidBrush(Color.Black)
         , e.Bounds
         , e.StringFormat
         e.Handled = true; //Indicating to grid not to draw this cell with its defaults

Note: This example bellow is simplified to be described in this short blog post.
I hope this demo will be useful. Good luck.

Categories: .Net, C# Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.