This project is read-only.

Need help to do matrix viewer

Jun 2, 2009 at 7:50 AM

I use the SourceGrid control as 2D data matrix viewer. I need to populate matrix of double about 2000 row with 30 colums with scientific format (E3)

The matrix must have a Colums & Rows header (columns and row indexes).

I must be able to select a specified range inside de matrix (submatrix) (so the GridSelectionMode must be set to Cell)

i tried : 

1) Grid control with two FOR loop with applying editor and view to each cell - Slow as hell


gEditor = new SourceGrid.Cells.Editors.TextBox(typeof(double));
gEditor.EnableEdit = false;
gEditor.TypeConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double), "E3");

// Populate Data
for (int i = 1; i <= matrix.Rows; i++)

                for (int j = 1; j <= matrix.Cols; j++)
                    this[i, j].Value = 0;// = new SourceGrid.Cells.Cell(matrix[(uint)i, (uint)j]);
                    this[i, j].Editor = gEditor;


2) ArrayGrid control with 2D double array - wow VERY FAST :)

3) DataGrid control populated with a row DataTable and sourcegrid.colums - slower than 2) but faster than 1)


The method 1) was too slow

The method 3) was abandonned because DataTable is row oriented and we can select only cell instead of complete row.

The method 2) seems appropriate but i can't get the set the cell format to regular instead of bold, there is no rows header and the headers are non-resizable

I need help to accomplish this task.

Thanks for your help.


Jun 2, 2009 at 10:40 AM

My god.. it was simplier than I tought !

I just discovered ArrayGrid.ValueCell ! So a ajusted the default cell editor & view for the string format 

I Used NumberTypeConverter to format the double matrix.

I fixed the column width with ArrayGrid.Column.ColumnWidth 


Finally I modified ArrayColumnHeaderModel & ArrayRowHeaderModel in ArrayGrid class to have header starting to 1 instead of 0 !

All working now perfectly.... and it's damn fast !

Sorry for having 'panicked'


Jun 2, 2009 at 12:07 PM

glad to hear it's working.

We'll work on the 1st point however, there is a "slight" problem in algorithm implementation :)

Oct 18, 2013 at 2:43 PM

I'm trying to do the exact same thing, but I'm having a bit of difficulty understanding. Do I just set ValueCell to 1? Can I still use a double[,] data source?