Example #1
0
        private void cbSpeed_SelectionChangeCommitted(object sender, EventArgs e)
        {
            if (updating)
            {
                return;
            }
            SyncedComboBox box = sender as SyncedComboBox;

            if (box == null)
            {
                return;
            }
            DataGridCell currentCell = dataGrid1.CurrentCell;
            DataTable    table       = dataGrid1.DataSource as DataTable;

            table.Rows[currentCell.RowNumber][currentCell.ColumnNumber] = (string)box.SelectedItem;
        }
Example #2
0
    private void FillGrid()
    {
      try
      {
        updating = true;
        //Declare and initialize local variables used
        DataColumn dtCol = null; //Data Column variable
        SyncedComboBox cbSpeed; //combo box var         
        SyncedComboBox cbSpeedDVD; //combo box var  
        SyncedCheckBox ckDisableDVD;

        //Create the Data Table object which will then be used to hold
        //columns and rows
        datasetFilters = new DataTable("Drive");
        //Add the columns to the DataColumn object
        dtCol = new DataColumn("Drive");
        dtCol.DataType = Type.GetType("System.String");
        dtCol.DefaultValue = "";
        datasetFilters.Columns.Add(dtCol);

        dtCol = new DataColumn("Name");
        dtCol.DataType = Type.GetType("System.String");
        dtCol.DefaultValue = "";
        datasetFilters.Columns.Add(dtCol);

        dtCol = new DataColumn("CD");
        dtCol.DataType = Type.GetType("System.String");
        dtCol.DefaultValue = "";
        datasetFilters.Columns.Add(dtCol);

        dtCol = new DataColumn("DisableCD");
        dtCol.DataType = Type.GetType("System.Boolean");
        dtCol.DefaultValue = false;
        dtCol.AllowDBNull = false;
        datasetFilters.Columns.Add(dtCol);

        dtCol = new DataColumn("DVD");
        dtCol.DataType = Type.GetType("System.String");
        dtCol.DefaultValue = "";
        datasetFilters.Columns.Add(dtCol);

        dtCol = new DataColumn("DisableDVD");
        dtCol.DataType = Type.GetType("System.Boolean");
        dtCol.DefaultValue = false;
        dtCol.AllowDBNull = false;
        datasetFilters.Columns.Add(dtCol);

        cbSpeed = new SyncedComboBox();
        cbSpeed.Cursor = Cursors.Arrow;
        cbSpeed.DropDownStyle = ComboBoxStyle.DropDownList;
        cbSpeed.Dock = DockStyle.Fill;
        cbSpeed.DisplayMember = "CD";
        cbSpeed.Grid = dataGrid1;
        cbSpeed.Cell = 1;
        cbSpeed.Items.AddRange(speeds);

        cbSpeedDVD = new SyncedComboBox();
        cbSpeedDVD.Cursor = Cursors.Arrow;
        cbSpeedDVD.DropDownStyle = ComboBoxStyle.DropDownList;
        cbSpeedDVD.Dock = DockStyle.Fill;
        cbSpeedDVD.DisplayMember = "DVD";
        cbSpeedDVD.Grid = dataGrid1;
        cbSpeedDVD.Cell = 1;
        cbSpeedDVD.Items.AddRange(speeds);

        ckDisableDVD = new SyncedCheckBox();
        ckDisableDVD.Cursor = Cursors.Arrow;
        ckDisableDVD.Cell = 1;
        ckDisableDVD.Grid = dataGrid1;

        //Event that will be fired when selected index in the combo box is changed
        cbSpeed.SelectionChangeCommitted += new EventHandler(cbSpeed_SelectionChangeCommitted);
        cbSpeedDVD.SelectionChangeCommitted += new EventHandler(cbSpeed_SelectionChangeCommitted);


        //fill in all rows...
        string[] drivespeedCD = _speedTableCD.Split(',');
        string[] drivespeedDVD = _speedTableDVD.Split(',');
        string[] disableCD = _disableCD.Split(',');
        string[] disableDVD = _disableDVD.Split(',');
        for (int i = 0; i < _driveCount; ++i)
        {
          bool disCD = (disableCD[i] == "Y");
          bool disDVD = (disableDVD[i] == "Y");
          datasetFilters.Rows.Add(
            new object[]
              {
                BassCd.BASS_CD_GetInfo(i).DriveLetter, BassCd.BASS_CD_GetInfo(i).vendor,
                drivespeedCD[i], disCD, drivespeedDVD[i], disDVD
              }
            );
        }

        //Set the Data Grid Source as the Data Table created above
        dataGrid1.CaptionText = string.Empty;
        dataGrid1.DataSource = datasetFilters;

        //set style property when first time the grid loads, next time onwards it //will maintain its property
        if (!dataGrid1.TableStyles.Contains("Drive"))
        {
          //Create a DataGridTableStyle object     
          DataGridTableStyle dgdtblStyle = new DataGridTableStyle();
          //Set its properties
          dgdtblStyle.MappingName = datasetFilters.TableName; //its table name of dataset
          dataGrid1.TableStyles.Add(dgdtblStyle);
          dgdtblStyle.RowHeadersVisible = false;
          dgdtblStyle.HeaderBackColor = Color.LightSteelBlue;
          dgdtblStyle.AllowSorting = false;
          dgdtblStyle.HeaderBackColor = Color.FromArgb(8, 36, 107);
          dgdtblStyle.RowHeadersVisible = false;
          dgdtblStyle.HeaderForeColor = Color.White;
          dgdtblStyle.HeaderFont = new Font("Microsoft Sans Serif", 9F, FontStyle.Bold, GraphicsUnit.Point, ((Byte)(0)));
          dgdtblStyle.GridLineColor = Color.DarkGray;
          dgdtblStyle.PreferredRowHeight = 22;
          dataGrid1.BackgroundColor = Color.White;

          //Take the columns in a GridColumnStylesCollection object and set //the size of the
          //individual columns   
          GridColumnStylesCollection colStyle;
          colStyle = dataGrid1.TableStyles[0].GridColumnStyles;
          colStyle[0].Width = 40;
          colStyle[0].ReadOnly = true;
          colStyle[1].Width = 265;
          colStyle[1].ReadOnly = true;
          colStyle[2].Width = 50;
          colStyle[3].Width = 15;
          colStyle[4].Width = 50;
          colStyle[5].Width = 15;
        }
        DataGridTextBoxColumn dgtb = (DataGridTextBoxColumn)dataGrid1.TableStyles[0].GridColumnStyles[2];
        //Add the combo box to the text box taken in the above step 
        dgtb.TextBox.Controls.Add(cbSpeed);
        dgtb = (DataGridTextBoxColumn)dataGrid1.TableStyles[0].GridColumnStyles[4];
        dgtb.TextBox.Controls.Add(cbSpeedDVD);
        updating = false;
      }
      catch (Exception ex)
      {
        Log.Error("Exception in CDSpeed FillGrid");
        Log.Error(ex);
      }
    }
Example #3
0
        private void FillGrid()
        {
            try
            {
                updating = true;
                //Declare and initialize local variables used
                DataColumn     dtCol = null; //Data Column variable
                SyncedComboBox cbSpeed;      //combo box var
                SyncedComboBox cbSpeedDVD;   //combo box var
                SyncedCheckBox ckDisableDVD;

                //Create the Data Table object which will then be used to hold
                //columns and rows
                datasetFilters = new DataTable("Drive");
                //Add the columns to the DataColumn object
                dtCol              = new DataColumn("Drive");
                dtCol.DataType     = Type.GetType("System.String");
                dtCol.DefaultValue = "";
                datasetFilters.Columns.Add(dtCol);

                dtCol              = new DataColumn("Name");
                dtCol.DataType     = Type.GetType("System.String");
                dtCol.DefaultValue = "";
                datasetFilters.Columns.Add(dtCol);

                dtCol              = new DataColumn("CD");
                dtCol.DataType     = Type.GetType("System.String");
                dtCol.DefaultValue = "";
                datasetFilters.Columns.Add(dtCol);

                dtCol              = new DataColumn("DisableCD");
                dtCol.DataType     = Type.GetType("System.Boolean");
                dtCol.DefaultValue = false;
                dtCol.AllowDBNull  = false;
                datasetFilters.Columns.Add(dtCol);

                dtCol              = new DataColumn("DVD");
                dtCol.DataType     = Type.GetType("System.String");
                dtCol.DefaultValue = "";
                datasetFilters.Columns.Add(dtCol);

                dtCol              = new DataColumn("DisableDVD");
                dtCol.DataType     = Type.GetType("System.Boolean");
                dtCol.DefaultValue = false;
                dtCol.AllowDBNull  = false;
                datasetFilters.Columns.Add(dtCol);

                cbSpeed               = new SyncedComboBox();
                cbSpeed.Cursor        = Cursors.Arrow;
                cbSpeed.DropDownStyle = ComboBoxStyle.DropDownList;
                cbSpeed.Dock          = DockStyle.Fill;
                cbSpeed.DisplayMember = "CD";
                cbSpeed.Grid          = dataGrid1;
                cbSpeed.Cell          = 1;
                cbSpeed.Items.AddRange(speeds);

                cbSpeedDVD               = new SyncedComboBox();
                cbSpeedDVD.Cursor        = Cursors.Arrow;
                cbSpeedDVD.DropDownStyle = ComboBoxStyle.DropDownList;
                cbSpeedDVD.Dock          = DockStyle.Fill;
                cbSpeedDVD.DisplayMember = "DVD";
                cbSpeedDVD.Grid          = dataGrid1;
                cbSpeedDVD.Cell          = 1;
                cbSpeedDVD.Items.AddRange(speeds);

                ckDisableDVD        = new SyncedCheckBox();
                ckDisableDVD.Cursor = Cursors.Arrow;
                ckDisableDVD.Cell   = 1;
                ckDisableDVD.Grid   = dataGrid1;

                //Event that will be fired when selected index in the combo box is changed
                cbSpeed.SelectionChangeCommitted    += new EventHandler(cbSpeed_SelectionChangeCommitted);
                cbSpeedDVD.SelectionChangeCommitted += new EventHandler(cbSpeed_SelectionChangeCommitted);


                //fill in all rows...
                string[] drivespeedCD  = _speedTableCD.Split(',');
                string[] drivespeedDVD = _speedTableDVD.Split(',');
                string[] disableCD     = _disableCD.Split(',');
                string[] disableDVD    = _disableDVD.Split(',');
                for (int i = 0; i < _driveCount; ++i)
                {
                    bool disCD  = (disableCD[i] == "Y");
                    bool disDVD = (disableDVD[i] == "Y");
                    datasetFilters.Rows.Add(
                        new object[]
                    {
                        BassCd.BASS_CD_GetInfo(i).DriveLetter, BassCd.BASS_CD_GetInfo(i).vendor,
                        drivespeedCD[i], disCD, drivespeedDVD[i], disDVD
                    }
                        );
                }

                //Set the Data Grid Source as the Data Table created above
                dataGrid1.CaptionText = string.Empty;
                dataGrid1.DataSource  = datasetFilters;

                //set style property when first time the grid loads, next time onwards it //will maintain its property
                if (!dataGrid1.TableStyles.Contains("Drive"))
                {
                    //Create a DataGridTableStyle object
                    DataGridTableStyle dgdtblStyle = new DataGridTableStyle();
                    //Set its properties
                    dgdtblStyle.MappingName = datasetFilters.TableName; //its table name of dataset
                    dataGrid1.TableStyles.Add(dgdtblStyle);
                    dgdtblStyle.RowHeadersVisible  = false;
                    dgdtblStyle.HeaderBackColor    = Color.LightSteelBlue;
                    dgdtblStyle.AllowSorting       = false;
                    dgdtblStyle.HeaderBackColor    = Color.FromArgb(8, 36, 107);
                    dgdtblStyle.RowHeadersVisible  = false;
                    dgdtblStyle.HeaderForeColor    = Color.White;
                    dgdtblStyle.HeaderFont         = new Font("Microsoft Sans Serif", 9F, FontStyle.Bold, GraphicsUnit.Point, ((Byte)(0)));
                    dgdtblStyle.GridLineColor      = Color.DarkGray;
                    dgdtblStyle.PreferredRowHeight = 22;
                    dataGrid1.BackgroundColor      = Color.White;

                    //Take the columns in a GridColumnStylesCollection object and set //the size of the
                    //individual columns
                    GridColumnStylesCollection colStyle;
                    colStyle             = dataGrid1.TableStyles[0].GridColumnStyles;
                    colStyle[0].Width    = 40;
                    colStyle[0].ReadOnly = true;
                    colStyle[1].Width    = 265;
                    colStyle[1].ReadOnly = true;
                    colStyle[2].Width    = 50;
                    colStyle[3].Width    = 15;
                    colStyle[4].Width    = 50;
                    colStyle[5].Width    = 15;
                }
                DataGridTextBoxColumn dgtb = (DataGridTextBoxColumn)dataGrid1.TableStyles[0].GridColumnStyles[2];
                //Add the combo box to the text box taken in the above step
                dgtb.TextBox.Controls.Add(cbSpeed);
                dgtb = (DataGridTextBoxColumn)dataGrid1.TableStyles[0].GridColumnStyles[4];
                dgtb.TextBox.Controls.Add(cbSpeedDVD);
                updating = false;
            }
            catch (Exception ex)
            {
                Log.Error("Exception in CDSpeed FillGrid");
                Log.Error(ex);
            }
        }