本文整理汇总了C#中System.Windows.Forms.ComboBox.SetBounds方法的典型用法代码示例。如果您正苦于以下问题:C# ComboBox.SetBounds方法的具体用法?C# ComboBox.SetBounds怎么用?C# ComboBox.SetBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ComboBox
的用法示例。
在下文中一共展示了ComboBox.SetBounds方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CatBox
public DialogResult CatBox(string promptText, double cost, DateTime dt, ref string value)
{
Form form = new Form();
Label label = new Label();
Label amount = new Label();
Label date = new Label();
ComboBox comboBox = new ComboBox();
Button buttonOk = new Button();
CheckBox checkBox = new CheckBox();
form.Text = "Specify a Category:";
label.Text = promptText;
amount.Text = cost.ToString("C");
date.Text = dt.ToString();
checkBox.Text = "Remember this relationship?";
buttonOk.Text = "OK";
buttonOk.DialogResult = DialogResult.OK;
label.SetBounds(9, 20, 172, 13);
amount.SetBounds(273, 20, 100, 13);
date.SetBounds(173, 20, 100, 13);
comboBox.SetBounds(12, 36, 372, 20);
buttonOk.SetBounds(309, 72, 75, 23);
checkBox.SetBounds(12, 72, 275, 24); // ???
label.AutoSize = true;
comboBox.Anchor = comboBox.Anchor | AnchorStyles.Right;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
checkBox.Anchor = checkBox.Anchor | AnchorStyles.Right;
comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
form.ClientSize = new Size(396, 107);
form.Controls.AddRange(new Control[] { label, amount, date, checkBox, comboBox, buttonOk });
form.ClientSize = new Size(Math.Max(300, amount.Right + 10), form.ClientSize.Height);
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
form.AcceptButton = buttonOk;
SqlCeConnection cs = new SqlCeConnection(@"Data Source = Expenses.sdf");
cs.Open();
SqlCeDataReader r = null;
SqlCeCommand getCats = new SqlCeCommand("SELECT * FROM Categories", cs);
r = getCats.ExecuteReader();
while (r.Read()) comboBox.Items.Add(r["Category"]);
cs.Close();
DialogResult dialogResult = form.ShowDialog();
value = comboBox.Text;
// remember relationship if option to do so is checked
if (checkBox.Checked)
{
SqlCeConnection cs2 = new SqlCeConnection(@"Data Source = Expenses.sdf");
cs2.Open();
SqlCeCommand setCat = new SqlCeCommand("INSERT INTO CategorizedItems VALUES (@Description, @Category)", cs2);
setCat.Parameters.AddWithValue("@Description", promptText);
setCat.Parameters.AddWithValue("@Category", value);
setCat.ExecuteNonQuery();
cs2.Close();
}
return dialogResult;
}
示例2: Show
/// <summary>
/// Shows a dialog box with an input field.
/// </summary>
/// <param name="title"></param>
/// <param name="prompt"></param>
/// <param name="options"></param>
/// <param name="value"></param>
/// <returns></returns>
public static DialogResult Show(string title, string prompt, List<string> options, ref string value)
{
Form mForm = new Form();
Label mLabel = new Label();
ComboBox mComboBox = new ComboBox();
Button mOKButton = new Button();
mForm.Text = title;
mLabel.Text = prompt;
mComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
for (int i = 0; i < options.Count; i++)
{
mComboBox.Items.Add(options[i]);
}
mComboBox.SelectedIndex = 0;
mOKButton.Text = "OK";
mOKButton.DialogResult = DialogResult.OK;
mForm.ClientSize = new Size(240, 80);
mLabel.SetBounds(4, 4, mForm.ClientSize.Width - 8, 22);
mComboBox.SetBounds(32, 26, mForm.ClientSize.Width - 64, 24);
mOKButton.SetBounds(mForm.ClientSize.Width / 2 - 32, 54, 64, 22);
mLabel.AutoSize = true;
mComboBox.Anchor = AnchorStyles.Bottom;
mOKButton.Anchor = AnchorStyles.Bottom;
mForm.Controls.AddRange(new Control[] { mLabel, mComboBox, mOKButton });
mForm.FormBorderStyle = FormBorderStyle.FixedDialog;
mForm.StartPosition = FormStartPosition.CenterScreen;
mForm.MinimizeBox = false;
mForm.MaximizeBox = false;
mForm.AcceptButton = mOKButton;
DialogResult dialogResult = mForm.ShowDialog();
value = mComboBox.Text;
return dialogResult;
}
示例3: InitForm
protected override void InitForm()
{
base.InitForm();
this._objectList = (ObjectList)Component;
this.CommitOnDeactivate = true;
this.Icon = new Icon(
typeof(System.Web.UI.Design.MobileControls.MobileControlDesigner),
"Commands.ico"
);
this.Size = new Size(402, 300);
this.Text = SR.GetString(SR.ObjectListCommandsPage_Title);
GroupLabel grplblCommandList = new GroupLabel();
grplblCommandList.SetBounds(4, 4, 392, LabelHeight);
grplblCommandList.Text = SR.GetString(SR.ObjectListCommandsPage_CommandListGroupLabel);
grplblCommandList.TabIndex = 0;
grplblCommandList.TabStop = false;
TreeList.TabIndex = 1;
Label lblText = new Label();
lblText.SetBounds(X, Y, ControlWidth, LabelHeight);
lblText.Text = SR.GetString(SR.ObjectListCommandsPage_TextCaption);
lblText.TabStop = false;
lblText.TabIndex = TabIndex;
_txtText = new TextBox();
Y += LabelHeight;
_txtText.SetBounds(X, Y, ControlWidth, CmbHeight);
_txtText.TextChanged += new EventHandler(this.OnPropertyChanged);
_txtText.TabIndex = TabIndex + 1;
GroupLabel grplblData = new GroupLabel();
grplblData.SetBounds(4, 238, 392, LabelHeight);
grplblData.Text = SR.GetString(SR.ObjectListCommandsPage_DataGroupLabel);
grplblData.TabIndex = TabIndex + 2;
grplblData.TabStop = false;
Label lblDefaultCommand = new Label();
lblDefaultCommand.SetBounds(8, 260, 182, LabelHeight);
lblDefaultCommand.Text = SR.GetString(SR.ObjectListCommandsPage_DefaultCommandCaption);
lblDefaultCommand.TabStop = false;
lblDefaultCommand.TabIndex = TabIndex + 3;
_cmbDefaultCommand = new ComboBox();
_cmbDefaultCommand.SetBounds(8, 276, 182, 64);
_cmbDefaultCommand.DropDownStyle = ComboBoxStyle.DropDown;
_cmbDefaultCommand.Sorted = true;
_cmbDefaultCommand.TabIndex = TabIndex + 4;
_cmbDefaultCommand.SelectedIndexChanged += new EventHandler(this.OnSetPageDirty);
_cmbDefaultCommand.TextChanged += new EventHandler(this.OnSetPageDirty);
this.Controls.AddRange(new Control[]
{
grplblCommandList,
lblText,
_txtText,
grplblData,
lblDefaultCommand,
_cmbDefaultCommand
});
}
示例4: cbFiltro_SelectedValueChanged
private void cbFiltro_SelectedValueChanged(object sender, EventArgs e)
{
pDinamico.Controls.Clear();
DataTable dt;
switch (cbFiltro.Text)
{
case "Cedula":
pDinamico.Controls.Add(lCedula);
pDinamico.Controls.Add(tbCedula);
break;
case "Region":
break;
case "VIP":
actualizarLista("select i.CustomerID, i.FirstName, i.LastName, SUM(soh.totaldue) as totalCompras from Individual i inner join SalesOrderHeader soh on i.CustomerID=soh.CustomerID group by i.CustomerID, i.FirstName, i.LastName HAVING SUM(soh.totaldue) > (select avg(totaldue) from SalesOrderHeader) order by totalCompras desc;");
break;
case "Categorias":
//sql
SqlDataAdapter dad = new SqlDataAdapter("SELECT name FROM ProductCategory",con);
dt = new DataTable();
dad.Fill(dt);
DataRow fila = dt.NewRow();
fila["Name"]="";
dt.Rows.Add(fila);
//crear combobox
//--Categorias
cbCategorias = new ComboBox();
cbCategorias.DataSource = dt;
cbCategorias.DisplayMember = "Name";
cbCategorias.ValueMember = "ProductCategoryId";
cbCategorias.SelectedValue = "";
cbCategorias.SelectedValueChanged += new System.EventHandler(this.cbCategorias_selectedValueChanged);
cbCategorias.SetBounds(0,0,100,20);
pDinamico.Controls.Add(cbCategorias);
patito = new Panel();
patito.SetBounds(120,0,130,50);
pDinamico.Controls.Add(patito);
actualizarLista("select i.CustomerID, i.FirstName, i.LastName from Individual i inner join SalesOrderHeader soh on soh.CustomerID = i.CustomerID inner join SalesOrderDetail sod on sod.SalesOrderID = soh.SalesOrderID inner join Product p on p.ProductID = sod.ProductID inner join ProductSubCategory ps on ps.ProductSubCategoryID = p.ProductSubCategoryID inner join ProductCategory pc on pc.ProductCategoryID = ps.ProductCategoryID and pc.ProductCategoryID = (select ProductCategoryID from ProductCategory where Name = '" + cbCategorias.Text + "') group by i.CustomerID, i.FirstName, i.LastName;");
break;
default:
actualizarLista( "select i.CustomerID, i.FirstName, i.LastName from Individual i inner join SalesOrderHeader soh on soh.CustomerID = i.CustomerID group by i.CustomerID, i.FirstName, i.LastName");
break;
}
}
示例5: ComboboxInputBox
private DialogResult ComboboxInputBox(string title, string promptText,
ref Object value, Object[] items)
{
Form form = new Form();
Label label = new Label();
ComboBox comboBox = new ComboBox();
comboBox.AutoCompleteMode = AutoCompleteMode.Suggest;
comboBox.AutoCompleteSource = AutoCompleteSource.ListItems;
Button buttonOk = new Button();
Button buttonCancel = new Button();
form.Text = title;
label.Text = promptText;
comboBox.Items.AddRange(items);
comboBox.SelectedIndex = 0;
buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
label.SetBounds(9, 20, 372, 13);
comboBox.SetBounds(12, 40, 372, 20);
buttonOk.SetBounds(228, 72, 75, 23);
buttonCancel.SetBounds(309, 72, 75, 23);
label.AutoSize = true;
comboBox.Anchor = comboBox.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, comboBox, 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 = comboBox.SelectedItem;
return dialogResult;
}
示例6: AddAccountForm
private static DialogResult AddAccountForm(ref LoLLauncherClient client)
{
Form form = new Form();
TextBox user = new TextBox();
TextBox pw = new TextBox();
ComboBox region = new ComboBox();
ComboBox queue = new ComboBox();
Button buttonOk = new Button();
Button buttonCancel = new Button();
user.Text = "Username";
pw.Text = "Password";
region.Text = "Region";
region.Items.AddRange(Enum.GetNames(typeof(LoLLauncher.Region)));
queue.Text = "Queue";
queue.Items.AddRange(Enum.GetNames(typeof(LoLLauncher.QueueTypes)));
buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
user.SetBounds(10, 10, 100, 23);
pw.SetBounds(120, 10, 100, 23);
region.SetBounds(10, 43, 100, 23);
queue.SetBounds(120, 43, 100, 23);
buttonOk.SetBounds(228, 72, 75, 23);
buttonCancel.SetBounds(309, 72, 75, 23);
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
form.ClientSize = new Size(396, 107);
form.Controls.AddRange(new Control[] { user, pw, region, queue, buttonOk, buttonCancel });
form.ClientSize = new Size(Math.Max(300, user.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();
if (dialogResult == DialogResult.OK)
{
client.Init(user.Text, pw.Text, (LoLLauncher.Region)Enum.Parse(typeof(LoLLauncher.Region), region.SelectedItem.ToString()),
(LoLLauncher.QueueTypes)Enum.Parse(typeof(LoLLauncher.QueueTypes), queue.SelectedItem.ToString()));
}
return dialogResult;
}
示例7: SearchDgv_Click
/// <summary>
/// 单击查询窗体datagridview
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SearchDgv_Click(object sender, EventArgs e)
{
//string sqlstatus = "SELECT NAME FROM SPFLOWSTATUS_TAB where id not in (6,8,9,15) ORDER BY ID";
string sqlstatus = "SELECT NAME FROM SP_FLOWSTATUS_TAB ORDER BY ID";
if (table_name == "SP_SPOOL_TAB" || table_name == "FLOWLOG_VIEW")
{
ComboBox cb = new ComboBox();
foreach( DataGridViewRow dr in this.SearchDgv.Rows )
{
if(dr.Cells[4].Selected == true)
{
int id = dr.Index;
if(dr.Cells[0].Value.ToString() == "FLOWSTATUS")
{
Rectangle rec = this.SearchDgv.GetCellDisplayRectangle(4, id, true);
cb.SetBounds(rec.Location.X, rec.Location.Y, rec.Width, rec.Height);
this.SearchDgv.Controls.Add(cb);
cb.Items.Add(string.Empty);
DetailInfo.Application_Code.FillComboBox.GetFlowStatus(cb,sqlstatus);
cb.BringToFront();
cb.SelectedIndexChanged += new EventHandler(cb_SelectedIndexChanged);
}
else
{
foreach (Control combo in this.SearchDgv.Controls)
{
if (combo is ComboBox)
{
combo.Dispose();
}
}
}
}
}
}
}
示例8: NewRaceInputBox
public NewRaceInputBox()
{
label = new Label();
label2 = new Label();
labelNote = new Label();
cbxGameName = new ComboBox();
cbxRunCategory = new ComboBox();
buttonOk = new Button();
buttonCancel = new Button();
Task.Factory.StartNew(() =>
{
try
{
var gameNames = SpeedRunsLiveAPI.Instance.GetGameNames().ToArray();
this.InvokeIfRequired(() =>
{
try
{
cbxGameName.Items.AddRange(gameNames);
}
catch (Exception ex)
{
Log.Error(ex);
}
});
}
catch (Exception ex)
{
Log.Error(ex);
}
});
cbxGameName.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
cbxGameName.TextChanged += cbxGameName_TextChanged;
cbxRunCategory.AutoCompleteSource = AutoCompleteSource.ListItems;
cbxRunCategory.Items.AddRange(new [] { "Any%", "Low%", "100%" });
cbxRunCategory.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
Text = "New Race";
label.Text = "Game:";
label2.Text = "Category:";
labelNote.Text = "Creating a race without any opponents is against the rules.";
buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
label.SetBounds(9, 20, 372, 13);
label2.SetBounds(9, 66, 372, 13);
cbxGameName.SetBounds(12, 36, 372, 20);
cbxRunCategory.SetBounds(12, 82, 372, 20);
labelNote.SetBounds(9, 118, 372, 13);
buttonOk.SetBounds(228, 145, 75, 23);
buttonCancel.SetBounds(309, 145, 75, 23);
label.AutoSize = true;
label2.AutoSize = true;
labelNote.AutoSize = true;
cbxGameName.Anchor = cbxGameName.Anchor | AnchorStyles.Right;
cbxRunCategory.Anchor = cbxGameName.Anchor | AnchorStyles.Right;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
ClientSize = new Size(396, 180);
Controls.AddRange(new Control[] { label, label2, labelNote, cbxGameName, cbxRunCategory, buttonOk, buttonCancel });
ClientSize = new Size(Math.Max(300, label.Right + 10), ClientSize.Height);
FormBorderStyle = FormBorderStyle.FixedDialog;
StartPosition = FormStartPosition.CenterScreen;
MinimizeBox = false;
MaximizeBox = false;
AcceptButton = buttonOk;
CancelButton = buttonCancel;
FormClosing += NewRaceInputBox_FormClosing;
cbxGameName.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
cbxRunCategory.AutoCompleteSource = AutoCompleteSource.ListItems;
cbxRunCategory.Items.AddRange(new string[] { "Any%", "Low%", "100%" });
cbxRunCategory.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
RefreshCategoryAutoCompleteList("");
}
示例9: InputBoxQuestScripts
public static DialogResult InputBoxQuestScripts(string title, string promptText, ref string value)
{
Form form = new Form();
Label label = new Label();
ComboBox comboBoxBox = new ComboBox();
Button buttonOk = new Button();
Button buttonCancel = new Button();
buttonOk.FlatStyle = FlatStyle.Flat;
buttonCancel.FlatStyle = FlatStyle.Flat;
comboBoxBox.FlatStyle = FlatStyle.Flat;
form.Text = title;
label.Text = promptText;
comboBoxBox.Text = value;
buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
label.SetBounds(9, 20, 372, 13);
comboBoxBox.SetBounds(12, 36, 372, 20);
buttonOk.SetBounds(228, 72, 75, 23);
buttonCancel.SetBounds(309, 72, 75, 23);
label.AutoSize = true;
comboBoxBox.Anchor = comboBoxBox.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, comboBoxBox, 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;
String[] QList = Directory.GetFiles("DIIIBData\\Quest", "*.D3S");
String CutDummy = String.Empty;
foreach (String Dummy in QList)
{
CutDummy = Dummy.Substring(16);
CutDummy = CutDummy.Substring(0, CutDummy.Length - 4);
comboBoxBox.Items.Add(CutDummy);
}
DialogResult dialogResult = form.ShowDialog();
if(comboBoxBox.SelectedIndex != -1)
value = comboBoxBox.Items[comboBoxBox.SelectedIndex].ToString();
return dialogResult;
}