public static DialogResult InputBox(string title, string promptText, ref string value) { Form form = new Form(); Label label = new Label(); MaskedTextBox textBox = new MaskedTextBox(); textBox.Text = value; SimpleButton buttonOk = new SimpleButton(); SimpleButton buttonCancel = new SimpleButton(); form.Text = title; label.Text = promptText; textBox.Text = value; buttonOk.Text = "Qəbul"; buttonCancel.Text = "İmtina"; buttonOk.DialogResult = DialogResult.OK; buttonCancel.DialogResult = DialogResult.Cancel; label.SetBounds(9, 20, 372, 13); textBox.SetBounds(12, 36, 372, 20); buttonOk.SetBounds(228, 72, 75, 23); buttonCancel.SetBounds(309, 72, 75, 23); label.AutoSize = true; textBox.Anchor = textBox.Anchor | AnchorStyles.Right; buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; form.ClientSize = new Size(396, 107); form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel }); form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height); form.FormBorderStyle = FormBorderStyle.FixedDialog; form.StartPosition = FormStartPosition.CenterScreen; form.MinimizeBox = false; form.MaximizeBox = false; form.AcceptButton = buttonOk; form.CancelButton = buttonCancel; DialogResult dialogResult = form.ShowDialog(); value = textBox.Text; return(dialogResult); }
public ArrayList ListaValores(Int32 inrLista, String idsWhere, Boolean multiselecao, String idsnovocabecalho = "") { MultiSelecao = multiselecao; frmLista = new DevExpress.XtraEditors.XtraForm(); Int32 iHeight = 0; Int32 iWidth = 0; String isqlConsulta = ""; try { tbDadosLista = new DataTable("dadosLista"); if (Conexao.getInstance().getConnection().State == ConnectionState.Open) { Object[] consulta = Utilidades.consultar(String.Format(" select ds_titulo,nr_altura,nr_largura,ds_instrucaosql from listavalores where nr_sequencial = {0}", inrLista)); if (consulta != null) { if (Convert.ToInt32(consulta[1]) > 0) { iHeight = Convert.ToInt32(consulta[1]); } if (Convert.ToInt32(consulta[2]) > 0) { iWidth = Convert.ToInt32(consulta[2]); } // se foi passado um novo cabeçalho, usa o que o usuário passou if (idsnovocabecalho.Trim().Length > 0) { frmLista.Text = idsnovocabecalho; } else { frmLista.Text = String.Format("({0}) - {1}", inrLista, Convert.ToString(consulta[0])); } isqlConsulta = Convert.ToString(consulta[3]); } if (!isqlConsulta.Equals("")) { isqlConsulta = isqlConsulta.Replace(":pDsWhere", idsWhere); NpgsqlCommand cmd = new NpgsqlCommand(isqlConsulta, Conexao.getInstance().getConnection()); NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(cmd); adapter.Fill(tbDadosLista); if (multiselecao) { tbDadosLista.Columns.Add("X", typeof(String)).SetOrdinal(0); } } } objRetorno = new ArrayList(); frmLista.ClientSize = new Size(iWidth, iHeight + 10); frmLista.Font = new Font("Tahoma", 9, FontStyle.Bold); frmLista.WindowState = FormWindowState.Normal; frmLista.FormBorderStyle = FormBorderStyle.FixedSingle; frmLista.StartPosition = FormStartPosition.CenterParent; frmLista.KeyPreview = true; frmLista.MaximizeBox = false; frmLista.MinimizeBox = false; frmLista.ShowInTaskbar = false; frmLista.ShowIcon = false; frmLista.TopMost = true; //Tamnho da Tela //frmLista.Size = new Size(700, 700); ctrlGrid = new DevExpress.XtraGrid.GridControl(); gridLst = new DevExpress.XtraGrid.Views.Grid.GridView(); ctrlGrid.Name = "ctrlGrid"; ctrlGrid.MainView = gridLst; gridLst.Name = "Grid"; gridLst.GridControl = ctrlGrid; ctrlGrid.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] { gridLst }); ctrlGrid.SetBounds(10, 60, iWidth - 20, iHeight - 85); ctrlGrid.DataSource = tbDadosLista; ctrlGrid.BindingContext = new BindingContext(); ctrlGrid.ForceInitialize(); gridLst.OptionsView.ShowFilterPanelMode = DevExpress.XtraGrid.Views.Base.ShowFilterPanelMode.Never; gridLst.OptionsView.ColumnAutoWidth = false; List <List <Object> > colunas = Conexao.getInstance().toList( " select nr_coluna,ds_titulocoluna,nm_campoinstrsql,nr_larguracampo,ds_alinhamentocampo " + " from listavalorescolunas " + " where nr_sequencial = " + inrLista); if (colunas != null) { if (multiselecao) { RepositoryItemCheckEdit selectdp = new RepositoryItemCheckEdit(); gridLst.Columns[0].ColumnEdit = selectdp; selectdp.NullText = "N"; selectdp.ValueChecked = "S"; selectdp.ValueUnchecked = "N"; selectdp.ValueGrayed = "N"; gridLst.Columns[0].Width = 25; gridLst.Columns[0].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; gridLst.Columns[0].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; //gridLst.Columns[0].AppearanceHeader.Font = new Font("Tahoma", 9, FontStyle.Bold); gridLst.Columns[0].Caption = ""; } foreach (List <Object> col in colunas) { Int32 nrColuna = multiselecao ? Convert.ToInt32(col.ElementAt(0)) + 1 : Convert.ToInt32(col.ElementAt(0)); gridLst.Columns[nrColuna - 1].Width = Convert.ToInt32(col.ElementAt(3)); gridLst.Columns[nrColuna - 1].OptionsColumn.AllowEdit = false; gridLst.Columns[nrColuna - 1].OptionsColumn.ReadOnly = true; gridLst.Columns[nrColuna - 1].Caption = Convert.ToString(col.ElementAt(1)); if ((col.ElementAt(4) != null ? col.ElementAt(4).ToString() : "Centralizado") == "Direita") { gridLst.Columns[nrColuna - 1].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far; gridLst.Columns[nrColuna - 1].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far; gridLst.Columns[nrColuna - 1].AppearanceHeader.Font = new Font("Tahoma", 9, FontStyle.Bold); } if ((col.ElementAt(4) != null ? col.ElementAt(4).ToString() : "Centralizado") == "Esquerda") { gridLst.Columns[nrColuna - 1].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near; gridLst.Columns[nrColuna - 1].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near; gridLst.Columns[nrColuna - 1].AppearanceHeader.Font = new Font("Tahoma", 9, FontStyle.Bold); } if ((col.ElementAt(4) != null ? col.ElementAt(4).ToString() : "Centralizado") == "Centralizado") { gridLst.Columns[nrColuna - 1].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; gridLst.Columns[nrColuna - 1].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; gridLst.Columns[nrColuna - 1].AppearanceHeader.Font = new Font("Tahoma", 9, FontStyle.Bold); } } } gridLst.GroupPanelText = "Arraste o Título das Colunas para Agrupar."; gridLst.Appearance.GroupPanel.Font = new Font("Tahoma", 9, FontStyle.Bold); gridLst.OptionsSelection.MultiSelect = multiselecao; gridLst.GroupPanelText = "Arraste o Título das Colunas para Agrupar."; gridLst.Appearance.GroupPanel.Font = new Font("Tahoma", 9, FontStyle.Bold); gridLst.OptionsSelection.MultiSelect = multiselecao; LabelControl lbFiltro = new LabelControl(); LabelControl lbInfo = new LabelControl(); TextEdit txtdsFiltro = new TextEdit(); lbFiltro.Text = "Filtro:"; lbFiltro.Font = new Font("Tahoma", 9, FontStyle.Bold); lbFiltro.SetBounds(7, 23, 50, 15); lbInfo.Font = new Font("Tahoma", 9, FontStyle.Bold); lbInfo.Text = "Duplo Clique no Registro para Confirmar a Seleção"; lbInfo.SetBounds(10, iHeight - 15, 350, 13); txtdsFiltro.Font = new Font("Tahoma", 9, FontStyle.Regular); txtdsFiltro.SetBounds(60, 20, 300, 20); txtdsFiltro.Properties.CharacterCasing = CharacterCasing.Upper; txtdsFiltro.TabIndex = 0; txtdsFiltro.TextChanged += new EventHandler(dsFiltroChanged); txtdsFiltro.KeyDown += new KeyEventHandler(dsFiltroEnter); ctrlGrid.TabIndex = 1; ctrlGrid.KeyDown += new KeyEventHandler(dsFiltroEnter); if (!multiselecao) { ctrlGrid.DoubleClick += new EventHandler(SelecionaRegistro); } frmLista.KeyDown += new KeyEventHandler(Escape); SimpleButton btnConfirmar = new SimpleButton(); btnConfirmar.SetBounds(iWidth - 110, iHeight - 20, 100, 25); btnConfirmar.Text = "Confirmar"; btnConfirmar.Font = new Font(btnConfirmar.Font, FontStyle.Bold); btnConfirmar.Font = new Font("Tahoma", 9, FontStyle.Bold); btnConfirmar.Click += new EventHandler(SelecionaRegistro); btnConfirmar.Image = Properties.Resources.Apply_16x16; //Desabilita a opção de agrupamento gridLst.OptionsView.ShowGroupPanel = false; frmLista.Controls.AddRange(new Control[] { ctrlGrid, lbFiltro, txtdsFiltro, lbInfo, btnConfirmar }); frmLista.ShowDialog(); frmLista.BringToFront(); } catch (Exception erro) { Alert.erro("Erro: " + erro.Message); } return(objRetorno); }
/// <summary> /// This method is used to add button on message box. /// </summary> /// <param name="MessageButton">MessageButton is type of enumMessageButton /// through which I get type of button which needs to be displayed.</param> private void addButton(enumMessageButton MessageButton) { switch (MessageButton) { case enumMessageButton.OK: { //If type of enumButton is OK then we add OK button only. SimpleButton btnOk = new SimpleButton(); //Create object of Button. btnOk.Text = "确定"; //Here we set text of Button. btnOk.Appearance.Font = new System.Drawing.Font("Tahoma", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); btnOk.DialogResult = DialogResult.Yes; //Set DialogResult property of button. btnOk.SetBounds(pnlShowMessage.ClientSize.Width / 2, 1, 105, 40); // Set bounds of button. //btnOk.Click += new EventHandler(btnOk_Click); pnlShowMessage.Controls.Add(btnOk); //Finally Add button control on panel. } break; case enumMessageButton.OKCancel: { Button btnOk = new Button(); btnOk.Text = "OK"; btnOk.DialogResult = DialogResult.OK; btnOk.FlatStyle = FlatStyle.Popup; btnOk.FlatAppearance.BorderSize = 0; btnOk.SetBounds((pnlShowMessage.ClientSize.Width - 70), 5, 65, 25); pnlShowMessage.Controls.Add(btnOk); Button btnCancel = new Button(); btnCancel.Text = "Cancel"; btnCancel.DialogResult = DialogResult.Cancel; btnCancel.FlatStyle = FlatStyle.Popup; btnCancel.FlatAppearance.BorderSize = 0; btnCancel.SetBounds((pnlShowMessage.ClientSize.Width - (btnOk.ClientSize.Width + 5 + 80)), 5, 75, 25); pnlShowMessage.Controls.Add(btnCancel); } break; case enumMessageButton.YesNo: { Button btnNo = new Button(); btnNo.Text = "No"; btnNo.DialogResult = DialogResult.No; btnNo.FlatStyle = FlatStyle.Popup; btnNo.FlatAppearance.BorderSize = 0; btnNo.SetBounds((pnlShowMessage.ClientSize.Width - 70), 5, 65, 25); pnlShowMessage.Controls.Add(btnNo); Button btnYes = new Button(); btnYes.Text = "Yes"; btnYes.DialogResult = DialogResult.Yes; btnYes.FlatStyle = FlatStyle.Popup; btnYes.FlatAppearance.BorderSize = 0; btnYes.SetBounds((pnlShowMessage.ClientSize.Width - (btnNo.ClientSize.Width + 5 + 80)), 5, 75, 25); pnlShowMessage.Controls.Add(btnYes); } break; case enumMessageButton.YesNoCancel: { Button btnCancel = new Button(); btnCancel.Text = "取消"; btnCancel.DialogResult = DialogResult.Cancel; btnCancel.FlatStyle = FlatStyle.Popup; btnCancel.FlatAppearance.BorderSize = 0; btnCancel.SetBounds((pnlShowMessage.ClientSize.Width - 70), 5, 65, 25); pnlShowMessage.Controls.Add(btnCancel); Button btnNo = new Button(); btnNo.Text = "No"; btnNo.DialogResult = DialogResult.No; btnNo.FlatStyle = FlatStyle.Popup; btnNo.FlatAppearance.BorderSize = 0; btnNo.SetBounds((pnlShowMessage.ClientSize.Width - (btnCancel.ClientSize.Width + 5 + 80)), 5, 75, 25); pnlShowMessage.Controls.Add(btnNo); Button btnYes = new Button(); btnYes.Text = "确定"; btnYes.DialogResult = DialogResult.No; btnYes.FlatStyle = FlatStyle.Popup; btnYes.FlatAppearance.BorderSize = 0; btnYes.SetBounds((pnlShowMessage.ClientSize.Width - (btnCancel.ClientSize.Width + btnNo.ClientSize.Width + 10 + 80)), 5, 75, 25); pnlShowMessage.Controls.Add(btnYes); } break; } }
public static DialogResult InputBox(string title, string promptText, ref string value) { /* * String txt = ""; * if (InputBox("Envio de e-mail", "Digite o e-mail para envio:", ref txt) == DialogResult.OK) { } * if (!txt.Equals(String.Empty)){ } */ XtraForm form = new XtraForm(); LabelControl label = new LabelControl(); TextEdit textBox = new TextEdit(); SimpleButton buttonCancel = new SimpleButton(); SimpleButton buttonOk = new SimpleButton(); form.Text = title; label.Text = promptText; textBox.Text = value; buttonOk.Text = "OK"; buttonOk.DialogResult = DialogResult.OK; buttonOk.Image = Properties.Resources.Apply_16x16; buttonCancel.Text = "Cancelar"; buttonCancel.DialogResult = DialogResult.Cancel; buttonCancel.Image = Properties.Resources.Cancel_16x16; label.SetBounds(7, 10, 372, 20); label.Font = new Font(label.Font, FontStyle.Bold); label.Font = new Font("Tahoma", 10, FontStyle.Bold); textBox.SetBounds(6, 36, 380, 50); textBox.Font = new Font("Tahoma", 10); buttonOk.SetBounds(220, 65, 75, 23); buttonOk.Font = new Font(buttonOk.Font, FontStyle.Bold); buttonOk.Font = new Font("Tahoma", 10, FontStyle.Bold); buttonCancel.SetBounds(300, 65, 85, 23); buttonCancel.Font = new Font(buttonCancel.Font, FontStyle.Bold); buttonCancel.Font = new Font("Tahoma", 10, FontStyle.Bold); label.AutoSize = true; textBox.Anchor = textBox.Anchor | AnchorStyles.Right; buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; form.ClientSize = new Size(396, 100); form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel }); form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height); form.FormBorderStyle = FormBorderStyle.FixedDialog; form.StartPosition = FormStartPosition.CenterScreen; form.MinimizeBox = false; form.MaximizeBox = false; form.ShowIcon = false; form.ShowInTaskbar = false; form.AcceptButton = buttonOk; form.CancelButton = buttonCancel; DialogResult dialogResult = form.ShowDialog(); value = textBox.Text; return(dialogResult); }