Inheritance: System.Windows.Forms.DataGridViewButtonColumn
        private void InitializeGridView(TabPage page)
        {
            if (dataGridView != null) {
                page.Controls.Add(dataGridView);
                page.Controls.Add(remove_as_template_button);
                return;
            }

            page.SuspendLayout();
            dataGridView = new DataGridView();
            colTitle = new DataGridViewTextBoxColumn();
            colField = new DataGridViewComboBoxColumn();
            colFieldName = new DataGridViewTextBoxColumn();
            colType = new DataGridViewComboBoxColumn();
            colOpt = new DataGridViewDisableButtonColumn();
            colOptionValue = new DataGridViewTextBoxColumn();
            //
            // dataGridView
            //
            dataGridView.AllowUserToResizeRows = false;
            dataGridView.MultiSelect = false;
            dataGridView.AllowDrop = true;
            dataGridView.AllowUserToDeleteRows = true;
            dataGridView.AutoGenerateColumns = false;

            dataGridView.EditMode = DataGridViewEditMode.EditOnEnter;
            dataGridView.DefaultValuesNeeded += dataGridView_DefaultValuesNeeded;
            dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            dataGridView.Columns.AddRange(new DataGridViewColumn[] {
            colTitle,
            colField,
            colFieldName,
            colType,
            colOpt,colOptionValue});
            dataGridView.Location = new Point(0, 0);
            dataGridView.Name = "dataGridView";
            dataGridView.Size = new System.Drawing.Size(TAB_WIDTH, TAB_HEIGHT);
            dataGridView.TabIndex = 0;
            dataGridView.DragDrop += dataGridView_DragDrop;
            dataGridView.DragOver += dataGridView_DragOver;
            dataGridView.MouseDown += dataGridView_MouseDown;
            dataGridView.MouseMove += dataGridView_MouseMove;
            dataGridView.CellEnter += dataGridView_CellEnter;
            dataGridView.MouseClick += dataGridView_MouseClick;
            dataGridView.RowValidating += dataGridView_RowValidating;
            dataGridView.CellValidating += dataGridView_CellValidating;
            dataGridView.RowStateChanged += dataGridView_RowStateChanged;
            dataGridView.SelectionChanged += dataGridView_SelectionChanged;
            dataGridView.CellClick += dataGridView_CellClick;
            dataGridView.EditingControlShowing += dataGridView_EditingControlShowing;
            //
            // colTitle
            //
            colTitle.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            colTitle.HeaderText = "Title";
            colTitle.Name = "colTitle";
            colTitle.SortMode = DataGridViewColumnSortMode.NotSortable;
            //
            // colField
            //
            colField.HeaderText = "Field";
            colField.Items.AddRange(new object[] {
            "Custom",
            "Title",
            "Username",
            "Password",
            "Password Confirmation",
            "URL",
            "Notes",
            "Override URL",
            "Expiry Date"});
            colField.Name = "colField";
            colField.Width = 105;
            colField.DropDownWidth = 180;

            //
            // colFieldName
            //
            colFieldName.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            colFieldName.HeaderText = "Field Name";
            colFieldName.Name = "colFieldName";
            colFieldName.SortMode = DataGridViewColumnSortMode.NotSortable;
            colFieldName.Width = 75;
            //
            // colType
            //
            colType.HeaderText = "Type";
            colType.Name = "colType";
            colType.Width = 100;
            colType.Items.AddRange(new object[] {
            "Inline",
            "Inline URL",
            "Popout",
            "Protected Inline",
            "Protected Popout",
            "Date",
            "Time",
            "Date Time",
            "Checkbox",
            "Divider",
            "Listbox"
            });
            colType.DropDownWidth = 150;
            colOpt.HeaderText = "Opt";
            colOpt.Name = "colOpt";
            colOpt.Width = 40;
            colOpt.UseColumnTextForButtonValue = true;
            colOpt.Text = "Opt";
            colOpt.ToolTipText = "Option";
            colOptionValue.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            colOptionValue.Visible = false;
            colOptionValue.Name = "colOptionValue";
            colOptionValue.Width = 0;

            page.Controls.Add(dataGridView);
            remove_as_template_button = new Button();
            remove_as_template_button.Text = "Remove As Template";
            remove_as_template_button.Width = TAB_WIDTH - 140 - 45;
            remove_as_template_button.Left = 115;
            //remove_as_template_button.Height = 28;
            remove_as_template_button.UseVisualStyleBackColor = true;
            dataGridView.Size = new Size(TAB_WIDTH, TAB_HEIGHT - remove_as_template_button.Height - 10); //have to set its size before setting the buttons size
            remove_as_template_button.Top = dataGridView.Height + 5;
            remove_as_template_button.Click += remove_as_template_button_Click;
            page.Controls.Add(remove_as_template_button);
            form.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            form.AutoScaleMode = AutoScaleMode.Font;
            page.ResumeLayout();
        }
Beispiel #2
0
        private void InitializeGridView(TabPage page)
        {
            if (dataGridView != null)
            {
                page.Controls.Add(dataGridView);
                page.Controls.Add(remove_as_template_button);
                return;
            }

            page.HorizontalScroll.Enabled = false;
            page.SuspendLayout();
            dataGridView   = new DataGridView();
            colTitle       = new DataGridViewTextBoxColumn();
            colField       = new DataGridViewComboBoxColumn();
            colFieldName   = new DataGridViewTextBoxColumn();
            colType        = new DataGridViewComboBoxColumn();
            colOpt         = new DataGridViewDisableButtonColumn();
            colOptionValue = new DataGridViewTextBoxColumn();
            //
            // dataGridView
            //
            dataGridView.AllowUserToResizeRows = false;
            dataGridView.MultiSelect           = false;
            dataGridView.AllowDrop             = true;
            dataGridView.AllowUserToDeleteRows = true;
            dataGridView.AutoGenerateColumns   = false;

            dataGridView.EditMode                    = DataGridViewEditMode.EditOnEnter;
            dataGridView.DefaultValuesNeeded        += dataGridView_DefaultValuesNeeded;
            dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            dataGridView.Columns.AddRange(new DataGridViewColumn[] {
                colTitle,
                colField,
                colFieldName,
                colType,
                colOpt, colOptionValue
            });
            dataGridView.Location = new Point(0, 0);
            dataGridView.Name     = "dataGridView";
            dataGridView.TabIndex = 0;
            SetBaseSizes(page);
            var template = new EntryTemplate(null, null, "DataGridView", 0, null);            //used just for the conrol sizing

            SetControlSizing(template, dataGridView);
            dataGridView.ScrollBars             = ScrollBars.None;
            dataGridView.DragDrop              += dataGridView_DragDrop;
            dataGridView.DragOver              += dataGridView_DragOver;
            dataGridView.MouseDown             += dataGridView_MouseDown;
            dataGridView.MouseMove             += dataGridView_MouseMove;
            dataGridView.CellEnter             += dataGridView_CellEnter;
            dataGridView.MouseClick            += dataGridView_MouseClick;
            dataGridView.RowValidating         += dataGridView_RowValidating;
            dataGridView.CellValidating        += dataGridView_CellValidating;
            dataGridView.RowStateChanged       += dataGridView_RowStateChanged;
            dataGridView.SelectionChanged      += dataGridView_SelectionChanged;
            dataGridView.CellClick             += dataGridView_CellClick;
            dataGridView.EditingControlShowing += dataGridView_EditingControlShowing;
            //
            // colTitle
            //
            colTitle.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            colTitle.HeaderText   = "Title";
            colTitle.Name         = "colTitle";
            colTitle.SortMode     = DataGridViewColumnSortMode.NotSortable;
            //
            // colField
            //
            colField.HeaderText = "Field";
            colField.Items.AddRange(new object[] {
                "Custom",
                "Title",
                "Username",
                "Password",
                "Password Confirmation",
                "URL",
                "Notes",
                "Override URL",
                "Expiry Date"
            });
            colField.Name          = "colField";
            colField.Width         = DpiUtil.ScaleIntX(105);
            colField.DropDownWidth = 180;


            //
            // colFieldName
            //
            colFieldName.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            colFieldName.HeaderText   = "Field Name";
            colFieldName.Name         = "colFieldName";
            colFieldName.SortMode     = DataGridViewColumnSortMode.NotSortable;
            colFieldName.Width        = DpiUtil.ScaleIntX(75);
            //
            // colType
            //
            colType.HeaderText = "Type";
            colType.Name       = "colType";
            colType.Width      = DpiUtil.ScaleIntX(100);
            colType.Items.AddRange(new object[] {
                "Inline",
                "Inline URL",
                "Popout",
                "Protected Inline",
                "Protected Popout",
                "Date",
                "Time",
                "Date Time",
                "Checkbox",
                "Divider",
                "Listbox",
                "RichTextbox"
            });
            colType.DropDownWidth = 150;
            colOpt.HeaderText     = "Npt";
            colOpt.Name           = "colOpt";
            colOpt.Width          = DpiUtil.ScaleIntX(40);
            colOpt.UseColumnTextForButtonValue = true;
            colOpt.Text                 = "Opt";
            colOpt.ToolTipText          = "Option";
            colOptionValue.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            colOptionValue.Visible      = false;
            colOptionValue.Name         = "colOptionValue";
            colOptionValue.Width        = 0;


            page.Controls.Add(dataGridView);
            remove_as_template_button        = new Button();
            remove_as_template_button.Text   = "Remove As Template";
            remove_as_template_button.Height = BUTTON_HEIGHT;
            remove_as_template_button.Width  = PAGE_WIDTH - DpiUtil.ScaleIntX(140) - DpiUtil.ScaleIntX(45);
            remove_as_template_button.Left   = DpiUtil.ScaleIntX(85);
            //remove_as_template_button.Height = 28;
            remove_as_template_button.UseVisualStyleBackColor = true;

            dataGridView.Tag = template;

            remove_as_template_button.Tag    = template;
            remove_as_template_button.Click += remove_as_template_button_Click;
            SetControlSizing(template, remove_as_template_button);
            page.Controls.Add(remove_as_template_button);
            page.ResumeLayout();
        }
Beispiel #3
0
        private void InitializeGridView(TabPage page)
        {
            if (dataGridView != null)
            {
                page.Controls.Add(dataGridView);
                page.Controls.Add(remove_as_template_button);
                return;
            }

            page.SuspendLayout();
            dataGridView   = new DataGridView();
            colTitle       = new DataGridViewTextBoxColumn();
            colField       = new DataGridViewComboBoxColumn();
            colFieldName   = new DataGridViewTextBoxColumn();
            colType        = new DataGridViewComboBoxColumn();
            colOpt         = new DataGridViewDisableButtonColumn();
            colOptionValue = new DataGridViewTextBoxColumn();
            //
            // dataGridView
            //
            dataGridView.AllowUserToResizeRows = false;
            dataGridView.MultiSelect           = false;
            dataGridView.AllowDrop             = true;
            dataGridView.AllowUserToDeleteRows = true;
            dataGridView.AutoGenerateColumns   = false;

            dataGridView.EditMode                    = DataGridViewEditMode.EditOnEnter;
            dataGridView.DefaultValuesNeeded        += dataGridView_DefaultValuesNeeded;
            dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            dataGridView.Columns.AddRange(new DataGridViewColumn[] {
                colTitle,
                colField,
                colFieldName,
                colType,
                colOpt, colOptionValue
            });
            dataGridView.Location               = new Point(0, 0);
            dataGridView.Name                   = "dataGridView";
            dataGridView.Size                   = new System.Drawing.Size(TAB_WIDTH, TAB_HEIGHT);
            dataGridView.TabIndex               = 0;
            dataGridView.DragDrop              += dataGridView_DragDrop;
            dataGridView.DragOver              += dataGridView_DragOver;
            dataGridView.MouseDown             += dataGridView_MouseDown;
            dataGridView.MouseMove             += dataGridView_MouseMove;
            dataGridView.CellEnter             += dataGridView_CellEnter;
            dataGridView.MouseClick            += dataGridView_MouseClick;
            dataGridView.RowValidating         += dataGridView_RowValidating;
            dataGridView.CellValidating        += dataGridView_CellValidating;
            dataGridView.RowStateChanged       += dataGridView_RowStateChanged;
            dataGridView.SelectionChanged      += dataGridView_SelectionChanged;
            dataGridView.CellClick             += dataGridView_CellClick;
            dataGridView.EditingControlShowing += dataGridView_EditingControlShowing;
            //
            // colTitle
            //
            colTitle.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            colTitle.HeaderText   = "Title";
            colTitle.Name         = "colTitle";
            colTitle.SortMode     = DataGridViewColumnSortMode.NotSortable;
            //
            // colField
            //
            colField.HeaderText = "Field";
            colField.Items.AddRange(new object[] {
                "Custom",
                "Title",
                "Username",
                "Password",
                "Password Confirmation",
                "URL",
                "Notes",
                "Override URL",
                "Expiry Date"
            });
            colField.Name          = "colField";
            colField.Width         = 105;
            colField.DropDownWidth = 180;


            //
            // colFieldName
            //
            colFieldName.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            colFieldName.HeaderText   = "Field Name";
            colFieldName.Name         = "colFieldName";
            colFieldName.SortMode     = DataGridViewColumnSortMode.NotSortable;
            colFieldName.Width        = 75;
            //
            // colType
            //
            colType.HeaderText = "Type";
            colType.Name       = "colType";
            colType.Width      = 100;
            colType.Items.AddRange(new object[] {
                "Inline",
                "Inline URL",
                "Popout",
                "Protected Inline",
                "Protected Popout",
                "Date",
                "Time",
                "Date Time",
                "Checkbox",
                "Divider",
                "Listbox"
            });
            colType.DropDownWidth = 150;
            colOpt.HeaderText     = "Opt";
            colOpt.Name           = "colOpt";
            colOpt.Width          = 40;
            colOpt.UseColumnTextForButtonValue = true;
            colOpt.Text                 = "Opt";
            colOpt.ToolTipText          = "Option";
            colOptionValue.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
            colOptionValue.Visible      = false;
            colOptionValue.Name         = "colOptionValue";
            colOptionValue.Width        = 0;


            page.Controls.Add(dataGridView);
            remove_as_template_button       = new Button();
            remove_as_template_button.Text  = "Remove As Template";
            remove_as_template_button.Width = TAB_WIDTH - 140 - 45;
            remove_as_template_button.Left  = 115;
            //remove_as_template_button.Height = 28;
            remove_as_template_button.UseVisualStyleBackColor = true;
            dataGridView.Size                = new Size(TAB_WIDTH, TAB_HEIGHT - remove_as_template_button.Height - 10); //have to set its size before setting the buttons size
            remove_as_template_button.Top    = dataGridView.Height + 5;
            remove_as_template_button.Click += remove_as_template_button_Click;
            page.Controls.Add(remove_as_template_button);
            form.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            form.AutoScaleMode       = AutoScaleMode.Font;
            page.ResumeLayout();
        }