private void makeGeotiffDataGridStyle()
        {
            if(m_geotiffTS != null)
            {
                return;
            }

            //STEP 1: Create a DataTable style object and set properties if required.
            m_geotiffTS = new DataGridTableStyle();
            //specify the table from dataset (required step)
            m_geotiffTS.MappingName = "geotiff";
            // Set other properties (optional step)
            //m_geotiffTS.AlternatingBackColor = Color.LightBlue;

            int colCount = 0;

            //STEP 1: Create an int column style and add it to the tablestyle
            //this requires setting the format for the column through its property descriptor
            PropertyDescriptorCollection pdc = this.BindingContext[m_geotiffDS, "geotiff"].GetItemProperties();
            //now created a formated column using the pdc
            DataGridDigitsTextBoxColumn csIDInt = new DataGridDigitsTextBoxColumn(pdc["id"], "i", true);
            csIDInt.MappingName = "id";
            csIDInt.HeaderText = "";
            csIDInt.Width = 30;
            csIDInt.ReadOnly = true;
            m_geotiffTS.GridColumnStyles.Add(csIDInt);
            colCount++;

            //STEP 2: Create a string column and add it to the tablestyle
            NameCol = new DataGridTextBoxColumn();
            NameCol.MappingName = "name"; //from dataset table
            NameCol.HeaderText = "Name";
            NameCol.Width = Math.Max(10, Project.nameColWidthCm);
            NameCol.ReadOnly = true;
            m_geotiffTS.GridColumnStyles.Add(NameCol);
            colCount++;

            //STEP 3: Add the checkbox
            DataGridColumnStyle boolCol = new MyDataGridBoolColumn(colCount);
            boolCol.MappingName = "displayed";
            boolCol.HeaderText = "Shown";
            //hook the new event to our handler in the grid
            ((MyDataGridBoolColumn)boolCol).BoolValueChanged += new BoolValueChangedEventHandler(HandleCustomMapShowChanges);
            //uncomment this line to get a two-state checkbox
            ((DataGridBoolColumn)boolCol).AllowNull = false;
            boolCol.Width = 45;
            m_geotiffTS.GridColumnStyles.Add(boolCol);
            colCount++;

            //STEP 3: Add the checkbox
            DataGridColumnStyle boolCol2 = new MyDataGridBoolColumn(colCount);
            boolCol2.MappingName = "persist";
            boolCol2.HeaderText = "Load on start";
            //hook the new event to our handler in the grid
            ((MyDataGridBoolColumn)boolCol2).BoolValueChanged += new BoolValueChangedEventHandler(HandleCustomMapPersistChanges);
            //uncomment this line to get a two-state checkbox
            ((DataGridBoolColumn)boolCol2).AllowNull = false;
            boolCol2.Width = 80;
            m_geotiffTS.GridColumnStyles.Add(boolCol2);
            colCount++;

            //STEP 4: Create a string column and add it to the tablestyle
            DescrCol = new DataGridTextBoxColumn();
            DescrCol.MappingName = "descr"; //from dataset table
            DescrCol.HeaderText = "Description";
            //DescrCol.Width = Math.Max(10, Project.descColWidthCm);
            DescrCol.Width = 1;
            DescrCol.ReadOnly = true;
            m_geotiffTS.GridColumnStyles.Add(DescrCol);
            colCount++;

            //STEP 5: Create a string column and add it to the tablestyle
            SourceCol = new DataGridTextBoxColumn();
            SourceCol.MappingName = "source"; //from dataset table
            SourceCol.HeaderText = "Source";
            int colWidthLeft = Math.Max(100, this.Width - csIDInt.Width - NameCol.Width - boolCol.Width - DescrCol.Width - 140);
            SourceCol.Width = Math.Max(colWidthLeft, 100); // Project.sourceColWidthCm);
            SourceCol.ReadOnly = true;
            m_geotiffTS.GridColumnStyles.Add(SourceCol);
            colCount++;

            geotiffDataGrid.CaptionVisible = false;

            //STEP 6: Add the tablestyle to your datagrid's tablestlye collection:
            geotiffDataGrid.TableStyles.Add(m_geotiffTS);

            /* how to test for checked checkboxes:
            if((bool)geotiffDataGrid[row, column])
                MessageBox.Show("I am true");
            else
                MessageBox.Show("I am false");
            */
        }
        private void makeTracksDataGridStyle()
        {
            if(m_tracksTS != null)
            {
                return;
            }

            //STEP 1: Create a DataTable style object and set properties if required.
            m_tracksTS = new DataGridTableStyle();
            //specify the table from dataset (required step)
            m_tracksTS.MappingName = "tracks";
            // Set other properties (optional step)
            //m_tracksTS.AlternatingBackColor = Color.LightBlue;

            int colCount = 0;

            //STEP 1: Create an int column style and add it to the tablestyle
            //this requires setting the format for the column through its property descriptor
            PropertyDescriptorCollection pdc = this.BindingContext[m_tracksDS, "tracks"].GetItemProperties();
            //now created a formated column using the pdc
            DataGridDigitsTextBoxColumn csIDInt = new DataGridDigitsTextBoxColumn(pdc["id"], "i", true);
            csIDInt.MappingName = "id";
            csIDInt.HeaderText = "";
            csIDInt.Width = 30;
            m_tracksTS.GridColumnStyles.Add(csIDInt);
            colCount++;

            //STEP 2: Create a string column and add it to the tablestyle
            DataGridColumnStyle NameCol = new DataGridTextBoxColumn();
            NameCol.MappingName = "name"; //from dataset table
            NameCol.HeaderText = "Name";
            NameCol.Width = 150;
            m_tracksTS.GridColumnStyles.Add(NameCol);
            colCount++;

            //STEP 3: Add the checkbox
            DataGridColumnStyle boolCol = new MyDataGridBoolColumn(colCount);
            boolCol.MappingName = "displayed";
            boolCol.HeaderText = "Shown";
            //hook the new event to our handler in the grid
            ((MyDataGridBoolColumn)boolCol).BoolValueChanged += new BoolValueChangedEventHandler(HandleTrackShowChanges);
            //uncomment this line to get a two-state checkbox
            ((DataGridBoolColumn)boolCol).AllowNull = false;
            boolCol.Width = 60;
            m_tracksTS.GridColumnStyles.Add(boolCol);
            colCount++;

            //STEP 4: Create an int column style and add it to the tablestyle
            //now created a formated column using the pdc
            DataGridDigitsTextBoxColumn csLegsInt = new DataGridDigitsTextBoxColumn(pdc["legs"], "i", true);
            csLegsInt.MappingName = "legs";
            csLegsInt.HeaderText = "Legs";
            csLegsInt.Width = 50;
            m_tracksTS.GridColumnStyles.Add(csLegsInt);
            colCount++;

            //STEP 5: Create a string column and add it to the tablestyle
            DataGridColumnStyle StartCol = new DataGridTextBoxColumn();
            StartCol.MappingName = "start"; //from dataset table
            StartCol.HeaderText = "Start";
            StartCol.Width = 170;
            m_tracksTS.GridColumnStyles.Add(StartCol);
            colCount++;

            //STEP 6: Create a string column and add it to the tablestyle
            DataGridColumnStyle EndCol = new DataGridTextBoxColumn();
            EndCol.MappingName = "end"; //from dataset table
            EndCol.HeaderText = "End";
            EndCol.Width = 170;
            m_tracksTS.GridColumnStyles.Add(EndCol);
            colCount++;

            //STEP 2: Create a string column and add it to the tablestyle
            DataGridColumnStyle DistanceCol = new DataGridTextBoxColumn();
            DistanceCol.MappingName = "distance";	//from dataset table
            DistanceCol.HeaderText = "";			// won't fit in 80 pixels
            DistanceCol.Width = 50;
            m_tracksTS.GridColumnStyles.Add(DistanceCol);
            colCount++;

            //STEP 7: Create a string column and add it to the tablestyle
            DataGridColumnStyle SourceCol = new DataGridTextBoxColumn();
            SourceCol.MappingName = "source"; //from dataset table
            SourceCol.HeaderText = "Info";
            SourceCol.Width = 800;
            m_tracksTS.GridColumnStyles.Add(SourceCol);
            colCount++;

            tracksDataGrid.CaptionVisible = false;

            //STEP 8: Add the tablestyle to your datagrid's tablestlye collection:
            tracksDataGrid.TableStyles.Add(m_tracksTS);

            /* how to test for checked checkboxes:
            if((bool)tracksDataGrid[row, column])
                MessageBox.Show("I am true");
            else
                MessageBox.Show("I am false");
            */
        }