Esempio n. 1
0
        private void makeUnrelatedDataGridStyle()
        {
            if(m_unrelatedTS != null)
            {
                return;
            }

            //STEP 1: Create a DataTable style object and set properties if required.
            m_unrelatedTS = new DataGridTableStyle();
            //specify the table from dataset (required step)
            m_unrelatedTS.MappingName = "unrelated";
            //m_unrelatedTS.RowHeadersVisible = false;
            // Set other properties (optional step)
            //m_unrelatedTS.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_unrelatedDS, "unrelated"].GetItemProperties();
            //now created a formated column using the pdc
            DataGridDigitsTextBoxColumn csIDInt = new DataGridDigitsTextBoxColumn(pdc["id"], "i", true);
            csIDInt.MappingName = "id";
            csIDInt.HeaderText = "";
            csIDInt.Width = 1;
            m_unrelatedTS.GridColumnStyles.Add(csIDInt);
            colCount++;

            //STEP 2: Create a button-like column and add it to the tablestyle
            DataGridColumnStyle ViewCol = new MyDataGridButtonColumn();
            ViewCol.MappingName = "view";
            ViewCol.HeaderText = "View";
            ViewCol.Width = 35;
            //hook the new event to our handler in the grid
            ((MyDataGridButtonColumn)ViewCol).CellButtonClick += new CellButtonClickEventHandler(HandleUnrelatedViewBtn);
            m_unrelatedTS.GridColumnStyles.Add(ViewCol);
            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_unrelatedTS.GridColumnStyles.Add(NameCol);
            colCount++;

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

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

            unrelatedDataGrid.CaptionVisible = false;

            //STEP 8: Add the tablestyle to your datagrid's tablestlye collection:
            unrelatedDataGrid.TableStyles.Add(m_unrelatedTS);
        }
        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 makeWaypointsDataGridStyle()
        {
            if(m_waypointsTS != null)
            {
                return;
            }

            //STEP 1: Create a DataTable style object and set properties if required.
            m_waypointsTS = new DataGridTableStyle();
            //specify the table from dataset (required step)
            m_waypointsTS.MappingName = "waypoints";
            // Set other properties (optional step)
            //m_waypointsTS.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_waypointsDS, "waypoints"].GetItemProperties();
            //now created a formated column using the pdc
            DataGridDigitsTextBoxColumn csIDInt = new DataGridDigitsTextBoxColumn(pdc["id"], "i", true);
            csIDInt.MappingName = "id";
            csIDInt.HeaderText = "";
            csIDInt.Width = 1;
            m_waypointsTS.GridColumnStyles.Add(csIDInt);
            colCount++;

            //STEP 7: Create a string column and add it to the tablestyle
            SymbolCol = new DataGridTextBoxColumn();
            SymbolCol.MappingName = "sym"; //from dataset table
            SymbolCol.HeaderText = "Symbol";
            SymbolCol.Width = Math.Max(10, Project.symbolColWidth);
            m_waypointsTS.GridColumnStyles.Add(SymbolCol);
            colCount++;

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

            //STEP 2: Create a string column and add it to the tablestyle
            UrlNameCol = new DataGridTextBoxColumn();
            UrlNameCol.MappingName = "urlname"; //from dataset table
            UrlNameCol.HeaderText = "URL Name";
            UrlNameCol.Width = Math.Max(10, Project.urlNameColWidth);
            m_waypointsTS.GridColumnStyles.Add(UrlNameCol);
            colCount++;

            //STEP 2: Create a string column and add it to the tablestyle
            DescCol = new DataGridTextBoxColumn();
            DescCol.MappingName = "desc"; //from dataset table
            DescCol.HeaderText = "Description";
            DescCol.Width = Math.Max(10, Project.descColWidth);
            m_waypointsTS.GridColumnStyles.Add(DescCol);
            colCount++;

            //STEP 2: Create a string column and add it to the tablestyle
            CommentCol = new DataGridTextBoxColumn();
            CommentCol.MappingName = "comment"; //from dataset table
            CommentCol.HeaderText = "Comment";
            CommentCol.Width = Math.Max(10, Project.commentColWidth);
            m_waypointsTS.GridColumnStyles.Add(CommentCol);
            colCount++;

            //STEP 5: Create a string column and add it to the tablestyle
            DataGridColumnStyle TimeCol = new DataGridTextBoxColumn();
            TimeCol.MappingName = "time"; //from dataset table
            TimeCol.HeaderText = "Time";
            TimeCol.Width = 1;
            m_waypointsTS.GridColumnStyles.Add(TimeCol);
            colCount++;

            //STEP 2: Create a string column and add it to the tablestyle
            DataGridColumnStyle LocationCol = new DataGridTextBoxColumn();
            LocationCol.MappingName = "location"; //from dataset table
            LocationCol.HeaderText = "Location";
            LocationCol.Width = 180;
            m_waypointsTS.GridColumnStyles.Add(LocationCol);
            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 = "Distance from Camera";	// won't fit in 80 pixels
            DistanceCol.Width = 80;
            m_waypointsTS.GridColumnStyles.Add(DistanceCol);
            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(HandleBoolChanges);
            //uncomment this line to get a two-state checkbox
            ((DataGridBoolColumn)boolCol).ReadOnly = true;
            ((DataGridBoolColumn)boolCol).AllowNull = false;
            boolCol.Width = 55;
            m_waypointsTS.GridColumnStyles.Add(boolCol);
            colCount++;
            */

            //STEP 2: Create a string column and add it to the tablestyle
            DataGridColumnStyle FoundCol = new DataGridTextBoxColumn();
            FoundCol.MappingName = "found"; //from dataset table
            FoundCol.HeaderText = "Found";
            FoundCol.Alignment = HorizontalAlignment.Center;
            FoundCol.Width = 45;
            m_waypointsTS.GridColumnStyles.Add(FoundCol);
            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 = "Source";
            SourceCol.Width = 800;
            m_waypointsTS.GridColumnStyles.Add(SourceCol);
            colCount++;

            waypointsDataGrid.CaptionVisible = false;

            //STEP 8: Add the tablestyle to your datagrid's tablestlye collection:
            waypointsDataGrid.TableStyles.Add(m_waypointsTS);
        }
        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");
            */
        }
        private void makeTrackpointsDataGridStyle()
        {
            bool fromRoutes = this.prevSelectedTab == this.routesTabPage;
            if(m_trackpointsTS == null)
            {
                //STEP 1: Create a DataTable style object and set properties if required.
                m_trackpointsTS = new DataGridTableStyle();
                //specify the table from dataset (required step)
                m_trackpointsTS.MappingName = "trackpoints";
                //m_trackpointsTS.RowHeadersVisible = false;
                // Set other properties (optional step)
                //m_trackpointsTS.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_trackpointsDS, "trackpoints"].GetItemProperties();
                //now created a formated column using the pdc
                DataGridDigitsTextBoxColumn csIDInt = new DataGridDigitsTextBoxColumn(pdc["id"], "i", true);
                csIDInt.MappingName = "id";
                csIDInt.HeaderText = "";
                csIDInt.Width = 1;
                m_trackpointsTS.GridColumnStyles.Add(csIDInt);
                colCount++;

                //STEP 1: Create an int column style and add it to the tablestyle
                //now created a formated column using the pdc
                DataGridDigitsTextBoxColumn csTrackIDInt = new DataGridDigitsTextBoxColumn(pdc["trackid"], "i", true);
                csTrackIDInt.MappingName = "trackid";
                csTrackIDInt.HeaderText = "Track Id";
                csTrackIDInt.Width = 1;
                m_trackpointsTS.GridColumnStyles.Add(csTrackIDInt);
                colCount++;

                //STEP 1: Create an int column style and add it to the tablestyle
                //now created a formated column using the pdc
                DataGridDigitsTextBoxColumn csWptIdxInt = new DataGridDigitsTextBoxColumn(pdc["wptidx"], "i", true);
                csWptIdxInt.MappingName = "wptidx";
                csWptIdxInt.HeaderText = "Wpt Idx";
                csWptIdxInt.Width = 1;
                m_trackpointsTS.GridColumnStyles.Add(csWptIdxInt);
                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_trackpointsTS.GridColumnStyles.Add(NameCol);
                colCount++;

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

                //STEP 2: Create a string column and add it to the tablestyle
                DataGridColumnStyle LocationCol = new DataGridTextBoxColumn();
                LocationCol.MappingName = "location"; //from dataset table
                LocationCol.HeaderText = "Location";
                LocationCol.Width = 180;
                m_trackpointsTS.GridColumnStyles.Add(LocationCol);
                colCount++;

                //STEP 3: Create a string column and add it to the tablestyle
                DataGridColumnStyle SpeedCol = new DataGridTextBoxColumn();
                SpeedCol.MappingName = "speed"; //from dataset table
                SpeedCol.HeaderText = "Speed";
                SpeedCol.Width = 80;
                m_trackpointsTS.GridColumnStyles.Add(SpeedCol);
                colCount++;

                //STEP 3: Create a string column and add it to the tablestyle
                DataGridColumnStyle HeadingCol = new DataGridTextBoxColumn();
                HeadingCol.MappingName = "heading"; //from dataset table
                HeadingCol.HeaderText = "heading";
                HeadingCol.Width = 80;
                m_trackpointsTS.GridColumnStyles.Add(HeadingCol);
                colCount++;

                //STEP 3: Create a string column and add it to the tablestyle
                DataGridColumnStyle LegCol = new DataGridTextBoxColumn();
                LegCol.MappingName = "leg"; //from dataset table
                LegCol.HeaderText = "Leg";
                LegCol.Width = 60;
                m_trackpointsTS.GridColumnStyles.Add(LegCol);
                colCount++;

                //STEP 3: Create a string column and add it to the tablestyle
                DataGridColumnStyle DistanceCol = new DataGridTextBoxColumn();
                DistanceCol.MappingName = "distance"; //from dataset table
                DistanceCol.HeaderText = "Odometer";
                DistanceCol.Width = 80;
                m_trackpointsTS.GridColumnStyles.Add(DistanceCol);
                colCount++;

                //STEP 4: Create a string column and add it to the tablestyle
                DataGridColumnStyle TrackCol = new DataGridTextBoxColumn();
                TrackCol.MappingName = "track"; //from dataset table
                TrackCol.HeaderText = "Track";
                TrackCol.Width = 150;
                m_trackpointsTS.GridColumnStyles.Add(TrackCol);
                colCount++;

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

                trackpointsDataGrid.CaptionVisible = false;

                //STEP 8: Add the tablestyle to your datagrid's tablestlye collection:
                trackpointsDataGrid.TableStyles.Add(m_trackpointsTS);
            }
            //m_trackpointsTS.GridColumnStyles[4].Width = fromRoutes ? 3 : 170;	// need to leave clickable area for sorting
            m_trackpointsTS.GridColumnStyles[6].Width = fromRoutes ? 1 : 80;
            m_trackpointsTS.GridColumnStyles[7].Width = fromRoutes ? 60 : 1;
            //m_trackpointsTS.GridColumnStyles[8].Width = fromRoutes ? 60 : 1;
            m_trackpointsTS.GridColumnStyles[10].HeaderText = fromRoutes ? "Route" : "Track";
        }
        private void makeDataGridTableStyle()
        {
            this.dataGridTableStyle = new DataGridTableStyle();

            this.dataGridTableStyle.DataGrid = this.favoritesDataGrid;
            this.dataGridTableStyle.HeaderForeColor = System.Drawing.SystemColors.ControlText;
            this.dataGridTableStyle.MappingName = "favoritesTable";

            //
            // nameDataGridTextBoxColumn
            //
            DataGridTextBoxColumn nameDataGridTextBoxColumn = new DataGridTextBoxColumn();
            nameDataGridTextBoxColumn.Format = "";
            nameDataGridTextBoxColumn.FormatInfo = null;
            nameDataGridTextBoxColumn.HeaderText = "Name";
            nameDataGridTextBoxColumn.MappingName = "name";
            nameDataGridTextBoxColumn.NullText = "";
            nameDataGridTextBoxColumn.Width = 200;
            this.dataGridTableStyle.GridColumnStyles.Add(nameDataGridTextBoxColumn);
            //
            // locationDataGridTextBoxColumn
            //
            DataGridTextBoxColumn locationDataGridTextBoxColumn = new DataGridTextBoxColumn();
            locationDataGridTextBoxColumn.Format = "";
            locationDataGridTextBoxColumn.FormatInfo = null;
            locationDataGridTextBoxColumn.HeaderText = "Location / Camera Altitude";
            locationDataGridTextBoxColumn.MappingName = "location";
            locationDataGridTextBoxColumn.NullText = "";
            locationDataGridTextBoxColumn.Width = 350;
            this.dataGridTableStyle.GridColumnStyles.Add(locationDataGridTextBoxColumn);

            // 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[favoritesDataSet, "favoritesTable"].GetItemProperties();
            //now created a formated column using the pdc
            DataGridDigitsTextBoxColumn csIDInt = new DataGridDigitsTextBoxColumn(pdc["id"], "i", true);
            csIDInt.MappingName = "id";
            csIDInt.HeaderText = "";
            csIDInt.Width = 1;
            dataGridTableStyle.GridColumnStyles.Add(csIDInt);

            /*
            //
            // latDataGridTextBoxColumn
            //
            DataGridTextBoxColumn latDataGridTextBoxColumn = new DataGridTextBoxColumn();
            latDataGridTextBoxColumn.Format = "";
            latDataGridTextBoxColumn.FormatInfo = null;
            latDataGridTextBoxColumn.HeaderText = "Latitude";
            latDataGridTextBoxColumn.MappingName = "lat";
            latDataGridTextBoxColumn.NullText = "";
            latDataGridTextBoxColumn.Width = 75;
            this.dataGridTableStyle.GridColumnStyles.Add(latDataGridTextBoxColumn);
            //
            // lngDataGridTextBoxColumn
            //
            DataGridTextBoxColumn lngDataGridTextBoxColumn = new DataGridTextBoxColumn();
            lngDataGridTextBoxColumn.Format = "";
            lngDataGridTextBoxColumn.FormatInfo = null;
            lngDataGridTextBoxColumn.HeaderText = "Longitude";
            lngDataGridTextBoxColumn.MappingName = "lng";
            lngDataGridTextBoxColumn.NullText = "";
            lngDataGridTextBoxColumn.Width = 75;
            this.dataGridTableStyle.GridColumnStyles.Add(lngDataGridTextBoxColumn);
            //
            // elevDataGridTextBoxColumn
            //
            DataGridTextBoxColumn elevDataGridTextBoxColumn = new DataGridTextBoxColumn();
            elevDataGridTextBoxColumn.Alignment = System.Windows.Forms.HorizontalAlignment.Right;
            elevDataGridTextBoxColumn.Format = "";
            elevDataGridTextBoxColumn.FormatInfo = null;
            elevDataGridTextBoxColumn.HeaderText = "Camera Altitude";
            elevDataGridTextBoxColumn.MappingName = "elev";
            elevDataGridTextBoxColumn.NullText = "";
            elevDataGridTextBoxColumn.Width = 120;
            this.dataGridTableStyle.GridColumnStyles.Add(elevDataGridTextBoxColumn);
            */

            favoritesDataGrid.CaptionVisible = false;
        }
        private void makeEqDataGridStyle()
        {
            if(m_eqTS != null)
            {
                return;
            }

            //STEP 1: Create a DataTable style object and set properties if required.
            m_eqTS = new DataGridTableStyle();
            //specify the table from dataset (required step)
            m_eqTS.MappingName = "eq";
            m_eqTS.RowHeadersVisible = false;
            // Set other properties (optional step)
            //m_eqTS.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_eqDS, "eq"].GetItemProperties();
            //now created a formated column using the pdc
            DataGridDigitsTextBoxColumn csIDInt = new DataGridDigitsTextBoxColumn(pdc["id"], "i", true);
            csIDInt.MappingName = "id";
            csIDInt.HeaderText = "";
            csIDInt.Width = 1;
            csIDInt.ReadOnly = true;
            m_eqTS.GridColumnStyles.Add(csIDInt);
            colCount++;

            //STEP 2: Create a double column and add it to the tablestyle
            DataGridColumnStyle MagnCol = new DataGridDigitsTextBoxColumn(pdc["magn"], "F1", true);
            MagnCol.MappingName = "magn"; //from dataset table
            MagnCol.HeaderText = "Magn";
            MagnCol.Width = 40;
            MagnCol.ReadOnly = true;
            m_eqTS.GridColumnStyles.Add(MagnCol);
            colCount++;

            //STEP 2: Create a string column and add it to the tablestyle
            DataGridColumnStyle LocCol = new DataGridTextBoxColumn();
            LocCol.MappingName = "location"; //from dataset table
            LocCol.HeaderText = "Location";
            LocCol.Width = 200;
            LocCol.ReadOnly = true;
            m_eqTS.GridColumnStyles.Add(LocCol);
            colCount++;

            //STEP 2: Create a string column and add it to the tablestyle
            DataGridColumnStyle QCol = new DataGridTextBoxColumn();
            QCol.MappingName = "quality"; //from dataset table
            QCol.HeaderText = "Quality";
            QCol.Width = 1;
            QCol.ReadOnly = true;
            m_eqTS.GridColumnStyles.Add(QCol);
            colCount++;

            //STEP 2: Create a string column and add it to the tablestyle
            DataGridColumnStyle ComCol = new DataGridTextBoxColumn();
            ComCol.MappingName = "comment"; //from dataset table
            ComCol.HeaderText = "Comment";
            ComCol.Width = 270;
            ComCol.ReadOnly = true;
            m_eqTS.GridColumnStyles.Add(ComCol);
            colCount++;

            //STEP 5: Create a string column and add it to the tablestyle
            m_timeCol = new DataGridTextBoxColumn();
            m_timeCol.MappingName = "time"; //from dataset table
            m_timeCol.HeaderText = "Time  " + (Project.useUtcTime ? "[UTC]" : "[your computer]");
            m_timeCol.Width = 170;
            m_timeCol.ReadOnly = true;
            m_eqTS.GridColumnStyles.Add(m_timeCol);
            colCount++;

            //STEP 3: Add the checkbox
            //DataGridColumnStyle boolCol = new MyDataGridBoolColumn(colCount);
            DataGridColumnStyle boolCol = new DataGridTextBoxColumn();
            boolCol.MappingName = "displayed";
            boolCol.HeaderText = "Shown";
            //hook the new event to our handler in the grid
            //((MyDataGridBoolColumn)boolCol).BoolValueChanged += new BoolValueChangedEventHandler(HandleEarthquakeShowChanges);
            //uncomment this line to get a two-state checkbox
            //((DataGridBoolColumn)boolCol).AllowNull = false;
            boolCol.Width = 60;
            boolCol.ReadOnly = true;
            boolCol.Alignment = HorizontalAlignment.Center;
            m_eqTS.GridColumnStyles.Add(boolCol);
            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 = "Source";
            SourceCol.Width = 100;
            SourceCol.ReadOnly = true;
            m_eqTS.GridColumnStyles.Add(SourceCol);
            colCount++;

            //STEP 7: Create a string column and add it to the tablestyle
            DataGridColumnStyle UrlCol = new DataGridTextBoxColumn();
            UrlCol.MappingName = "url"; //from dataset table
            UrlCol.HeaderText = "URL";
            UrlCol.Width = 500;
            UrlCol.ReadOnly = true;
            m_eqTS.GridColumnStyles.Add(UrlCol);
            colCount++;

            eqDataGrid.CaptionVisible = false;

            //STEP 8: Add the tablestyle to your datagrid's tablestlye collection:
            eqDataGrid.TableStyles.Clear();
            eqDataGrid.TableStyles.Add(m_eqTS);

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