本文整理汇总了C#中System.Windows.Forms.CheckBox.SetBounds方法的典型用法代码示例。如果您正苦于以下问题:C# CheckBox.SetBounds方法的具体用法?C# CheckBox.SetBounds怎么用?C# CheckBox.SetBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.CheckBox
的用法示例。
在下文中一共展示了CheckBox.SetBounds方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDrawColumnHeader
protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
{
base.OnDrawColumnHeader(e);
if (e.ColumnIndex == 0)
{
var headerCheckBox = new CheckBox {Text = "", Visible = true};
SuspendLayout();
e.DrawBackground();
headerCheckBox.BackColor = Color.Transparent;
headerCheckBox.UseVisualStyleBackColor = true;
headerCheckBox.BackgroundImage = Resources.ListViewHeaderCheckboxBackgroud;
headerCheckBox.SetBounds(e.Bounds.X, e.Bounds.Y,
headerCheckBox.GetPreferredSize(new Size(e.Bounds.Width, e.Bounds.Height)).
Width,
headerCheckBox.GetPreferredSize(new Size(e.Bounds.Width, e.Bounds.Height)).
Height);
headerCheckBox.Size =
new Size(headerCheckBox.GetPreferredSize(new Size(e.Bounds.Width - 1, e.Bounds.Height)).Width + 1,
e.Bounds.Height);
headerCheckBox.Location = new Point(4, 0);
Controls.Add(headerCheckBox);
headerCheckBox.Show();
headerCheckBox.BringToFront();
e.DrawText(TextFormatFlags.VerticalCenter | TextFormatFlags.Left);
headerCheckBox.CheckedChanged += OnHeaderCheckboxCheckedChanged;
ResumeLayout(true);
}
else
{
e.DrawDefault = true;
}
}
示例2: 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;
}
示例3: Show
/// <summary>
/// Displays a dialog with a prompt and textbox where the user can enter information
/// </summary>
/// <param name="title">Dialog title</param>
/// <param name="promptText">Dialog prompt</param>
/// <param name="value">Sets the initial value and returns the result</param>
/// <returns>Dialog result</returns>
public static DialogResult Show(Form parent, string title, string promptText, string checkText, ref string value, ref bool isChecked)
{
// TODO: button placement/size has been hardcoded for how it is used in this app.
Form form = new Form();
Label label = new Label();
TextBox textBox = new TextBox();
Button buttonOk = new Button();
Button buttonCancel = new Button();
CheckBox checkBox = new CheckBox();
form.Text = title;
label.Text = promptText;
textBox.Text = value;
textBox.Multiline = true;
textBox.Height = (int)(textBox.Height * 2);
checkBox.Checked = isChecked;
checkBox.Text = checkText;
checkBox.Visible = (checkText != null);
//form.TopLevel = true;
//form.StartPosition = FormStartPosition.CenterParent;
//form.Parent = parent;
buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
label.SetBounds(9, 20, 372, 13);
textBox.SetBounds(12, 76, 372, 50);
buttonOk.SetBounds(228, 130, 75, 23);
buttonCancel.SetBounds(309, 130, 75, 23);
checkBox.SetBounds(12, 60, 150, 23);
label.AutoSize = true;
textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
checkBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
form.ClientSize = new Size(396, 170);
form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel, checkBox });
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;
isChecked = checkBox.Checked;
return dialogResult;
}
示例4: InputCreateRoomBox
public static TDSRoom InputCreateRoomBox(TDSRoom currentRoom)
{
var form = new Form();
var westRadioButton = new RadioButton {Text = "To the west", Enabled = false};
var eastRadioButton = new RadioButton {Text = "To the east", Enabled = false};
var northRadioButton = new RadioButton {Text = "To the north", Enabled = false};
var southRadioButton = new RadioButton {Text = "To the south", Enabled = false};
var isRequiredCheckBox = new CheckBox {Text = "Is required", Checked = true};
var isSecretCheckBox = new CheckBox {Text = "Is secret", Checked = false};
var doneButton = new Button {Text = "OK"};
form.Text = "Create new room";
form.ClientSize = new Size(396, 200);
form.Controls.AddRange(new Control[]
{
westRadioButton, eastRadioButton, northRadioButton, southRadioButton,
isRequiredCheckBox, isSecretCheckBox, doneButton
});
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
westRadioButton.SetBounds(25, 25, 100, 25);
eastRadioButton.SetBounds(25, 50, 100, 25);
northRadioButton.SetBounds(25, 75, 100, 25);
southRadioButton.SetBounds(25, 100, 100, 25);
isRequiredCheckBox.SetBounds(125, 25, 100, 25);
isSecretCheckBox.SetBounds(125, 50, 100, 25);
doneButton.SetBounds(125, 100, 100, 25);
if (currentRoom.Level.GetRoom(currentRoom.X - 1, currentRoom.Y) == null) westRadioButton.Enabled = true;
if (currentRoom.Level.GetRoom(currentRoom.X + 1, currentRoom.Y) == null) eastRadioButton.Enabled = true;
if (currentRoom.Level.GetRoom(currentRoom.X, currentRoom.Y - 1) == null) northRadioButton.Enabled = true;
if (currentRoom.Level.GetRoom(currentRoom.X, currentRoom.Y + 1) == null) southRadioButton.Enabled = true;
TDSRoom result = null;
var resultX = 0;
var resultY = 0;
doneButton.Click += (e, sender) =>
{
if (westRadioButton.Checked) resultX = -1;
if (eastRadioButton.Checked) resultX = 1;
if (northRadioButton.Checked) resultY = -1;
if (southRadioButton.Checked) resultY = 1;
result = TDSControl.CreateRoom(currentRoom.Level, currentRoom.X + resultX, currentRoom.Y + resultY, isRequiredCheckBox.Checked, isSecretCheckBox.Checked);
form.Close();
};
form.ShowDialog();
return result;
}
示例5: Clear_Click
private void Clear_Click(object sender, EventArgs e)
{
Form form = new Form(); form.Text = "Clear Databases";
CheckBox clearCategories = new CheckBox();
clearCategories.Text = "Clear All Categories, Expenses, and Relations";
clearCategories.Checked = false;
clearCategories.SetBounds(9, 6, 272, 24);
CheckBox clearLineItems = new CheckBox();
clearLineItems.Text = "Clear Line Item Expenses Only";
clearLineItems.Checked = false;
clearLineItems.SetBounds(9, 30, 272, 24);
CheckBox clearRelations = new CheckBox();
clearRelations.Text = "Clear Saved Relations Only";
clearRelations.Checked = false;
clearRelations.SetBounds(9, 54, 272, 24);
Button OK = new Button(); OK.Text = "OK";
OK.SetBounds(9, 78, 75, 23);
OK.DialogResult = DialogResult.OK;
Button Cancel = new Button(); Cancel.Text = "Cancel";
Cancel.SetBounds(100, 78, 75, 23);
Cancel.DialogResult = DialogResult.Cancel;
form.ClientSize = new Size(296, 107);
form.Controls.AddRange(new Control[] { clearCategories, clearLineItems, clearRelations, OK, Cancel });
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
form.AcceptButton = OK;
form.CancelButton = Cancel;
if (form.ShowDialog() == DialogResult.OK)
{
if (clearCategories.Checked)
{
File.Delete("Expenses.sdf");
Setup.Enabled = true; Edit.Enabled = false; Clear.Enabled = false;
View.Enabled = false; Import.Enabled = false; Manual.Enabled = false;
}
else if (clearLineItems.Checked)
{
if (clearRelations.Checked) Form1_Helper.ClearRelations();
Form1_Helper.ClearLineItems();
}
else if (clearRelations.Checked) Form1_Helper.ClearRelations();
else MessageBox.Show("No action taken.");
}
else MessageBox.Show("No action taken.");
}
示例6: InitForm
protected override void InitForm()
{
Debug.Assert(GetBaseControl() != null);
_isBaseControlList = (GetBaseControl() is List);
this._listDesigner = (IListDesigner)GetBaseDesigner();
Y = (_isBaseControlList ? 52 : 24);
base.InitForm();
this.Text = SR.GetString(SR.ListItemsPage_Title);
this.CommitOnDeactivate = true;
this.Icon = new Icon(
typeof(System.Web.UI.Design.MobileControls.MobileControlDesigner),
"Items.ico"
);
this.Size = new Size(382, 220);
if (_isBaseControlList)
{
_itemsAsLinksCheckBox = new CheckBox();
_itemsAsLinksCheckBox.SetBounds(4, 4, 370, 16);
_itemsAsLinksCheckBox.Text = SR.GetString(SR.ListItemsPage_ItemsAsLinksCaption);
_itemsAsLinksCheckBox.FlatStyle = FlatStyle.System;
_itemsAsLinksCheckBox.CheckedChanged += new EventHandler(this.OnSetPageDirty);
_itemsAsLinksCheckBox.TabIndex = 0;
}
GroupLabel grplblItemList = new GroupLabel();
grplblItemList.SetBounds(4, _isBaseControlList ? 32 : 4, 372, LabelHeight);
grplblItemList.Text = SR.GetString(SR.ListItemsPage_ItemListGroupLabel);
grplblItemList.TabIndex = 1;
grplblItemList.TabStop = false;
TreeList.TabIndex = 2;
Label lblValue = new Label();
lblValue.SetBounds(X, Y, 134, LabelHeight);
lblValue.Text = SR.GetString(SR.ListItemsPage_ItemValueCaption);
lblValue.TabStop = false;
lblValue.TabIndex = Index;
Y += LabelHeight;
_txtValue = new TextBox();
_txtValue.SetBounds(X, Y, 134, CmbHeight);
_txtValue.TextChanged += new EventHandler(this.OnPropertyChanged);
_txtValue.TabIndex = Index + 1;
this.Controls.AddRange(new Control[]
{
grplblItemList,
lblValue,
_txtValue
});
if (_isBaseControlList)
{
this.Controls.Add(_itemsAsLinksCheckBox);
}
else
{
Y += CellSpace;
_ckbSelected = new CheckBox();
_ckbSelected.SetBounds(X, Y, 134, LabelHeight);
_ckbSelected.FlatStyle = System.Windows.Forms.FlatStyle.System;
_ckbSelected.Text = SR.GetString(SR.ListItemsPage_ItemSelectedCaption);
_ckbSelected.CheckedChanged += new EventHandler(this.OnPropertyChanged);
_ckbSelected.TabIndex = Index + 2;
this.Controls.Add(_ckbSelected);
}
}
示例7: 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),
"Fields.ico"
);
this.Size = new Size(402, 300);
this.Text = SR.GetString(SR.ObjectListFieldsPage_Title);
_ckbAutoGenerateFields = new CheckBox();
_cmbDataField = new UnsettableComboBox();
_ckbVisible = new CheckBox();
_txtDataFormatString = new TextBox();
_txtTitle = new TextBox();
_ckbAutoGenerateFields.SetBounds(4, 4, 396, LabelHeight);
_ckbAutoGenerateFields.Text = SR.GetString(SR.ObjectListFieldsPage_AutoGenerateFieldsCaption);
_ckbAutoGenerateFields.FlatStyle = FlatStyle.System;
_ckbAutoGenerateFields.CheckedChanged += new EventHandler(this.OnSetPageDirty);
_ckbAutoGenerateFields.TabIndex = 0;
GroupLabel grplblFieldList = new GroupLabel();
grplblFieldList.SetBounds(4, 32, 392, LabelHeight);
grplblFieldList.Text = SR.GetString(SR.ObjectListFieldsPage_FieldListGroupLabel);
grplblFieldList.TabIndex = 1;
grplblFieldList.TabStop = false;
TreeList.TabIndex = 2;
Label lblDataField = new Label();
lblDataField.SetBounds(X, Y, ControlWidth, LabelHeight);
lblDataField.Text = SR.GetString(SR.ObjectListFieldsPage_DataFieldCaption);
lblDataField.TabStop = false;
lblDataField.TabIndex = Index;
Y += LabelHeight;
_cmbDataField.SetBounds(X, Y, ControlWidth, CmbHeight);
_cmbDataField.DropDownStyle = ComboBoxStyle.DropDown;
_cmbDataField.Sorted = true;
_cmbDataField.NotSetText = SR.GetString(SR.ObjectListFieldsPage_NoneComboEntry);
_cmbDataField.TextChanged += new EventHandler(this.OnPropertyChanged);
_cmbDataField.SelectedIndexChanged += new EventHandler(this.OnPropertyChanged);
_cmbDataField.TabIndex = Index + 1;
Y += CellSpace;
Label lblDataFormatString = new Label();
lblDataFormatString.SetBounds(X, Y, ControlWidth, LabelHeight);
lblDataFormatString.Text = SR.GetString(SR.ObjectListFieldsPage_DataFormatStringCaption);
lblDataFormatString.TabStop = false;
lblDataFormatString.TabIndex = Index + 2;
Y += LabelHeight;
_txtDataFormatString.SetBounds(X, Y, ControlWidth, CmbHeight);
_txtDataFormatString.TextChanged += new EventHandler(this.OnPropertyChanged);
_txtDataFormatString.TabIndex = Index + 3;
Y += CellSpace;
Label lblTitle = new Label();
lblTitle.SetBounds(X, Y, ControlWidth, LabelHeight);
lblTitle.Text = SR.GetString(SR.ObjectListFieldsPage_TitleCaption);
lblTitle.TabStop = false;
lblTitle.TabIndex = Index + 4;
Y += LabelHeight;
_txtTitle.SetBounds(X, Y, ControlWidth, CmbHeight);
_txtTitle.TextChanged += new EventHandler(this.OnPropertyChanged);
_txtTitle.TabIndex = Index + 5;
Y += CellSpace;
_ckbVisible.SetBounds(X, Y, ControlWidth, CmbHeight);
_ckbVisible.FlatStyle = System.Windows.Forms.FlatStyle.System;
_ckbVisible.Text = SR.GetString(SR.ObjectListFieldsPage_VisibleCaption);
_ckbVisible.CheckedChanged += new EventHandler(this.OnPropertyChanged);
_ckbVisible.TabIndex = Index + 6;
this.Controls.AddRange(new Control[] {
_ckbAutoGenerateFields,
grplblFieldList,
lblDataField,
_cmbDataField,
lblDataFormatString,
_txtDataFormatString,
lblTitle,
_txtTitle,
_ckbVisible
});
}
示例8: InitializeToolButtons
/// <summary>
/// показать выбранные кнопки инструментальной панели
/// </summary>
private void InitializeToolButtons(List<ChartToolButtonSettings> buttons, Control panel)
{
const int buttonMarging = 3;
var buttonTop = toolBtnCross.Top;
var firstUserButtonX = btnFlipPanelChartTools.Right + buttonMarging;
var buttonSize = toolBtnCross.Size;
// удалить кнопки
while (panel.Controls.Count > 1)
panel.Controls.RemoveAt(1);
// добавить кнопки
var left = firstUserButtonX;
foreach (var btnDescr in buttons)
{
if (btnDescr.Group != null)
continue;
var button = new CheckBox
{
Parent = panel,
ImageIndex = btnDescr.Image,
Tag = btnDescr,
Appearance = Appearance.Button,
//FlatStyle = FlatStyle.Flat,
ImageList = lstGlyph32,
};
// кнопка "Курсор" нажата по-умолчанию
if (btnDescr.ButtonType == ChartToolButtonSettings.ToolButtonType.Chart &&
btnDescr.Tool == CandleChartControl.ChartTool.Cursor)
button.Checked = true;
// кнопки "Запустить роботов", "Портфель роботов", "Состояние роботов"
UpdateRobotIconUnsafe(robotFarm != null ? robotFarm.State : RobotFarm.RobotFarmState.Stopped);
buttonToolTip.SetToolTip(button, btnDescr.ToString());
if (btnDescr.IsVisibleDisplayName)
{
button.Text = btnDescr.ToString();
var len = (int) button.CreateGraphics().MeasureString(button.Text, button.Font).Width +
lstGlyph32.ImageSize.Width + 16;
button.SetBounds(left, buttonTop, len, buttonSize.Height);
left += (len + buttonMarging);
button.ImageAlign = ContentAlignment.MiddleLeft;
button.TextAlign = ContentAlignment.MiddleRight;
}
else
{
button.SetBounds(left, buttonTop, buttonSize.Width, buttonSize.Height);
left += (buttonSize.Width + buttonMarging);
}
button.Click += ToolStripBtnClick;
// добавить в панель
panel.Controls.Add(button);
}
// добавить кнопки-менюшки
var groupBtnWidth = buttonSize.Width + 12;
var buttonGroups = buttons.Where(b => b.Group != null).Select(b => b.Group).Distinct().ToList();
foreach (var group in buttonGroups)
{
var groupBtn = new Button
{
Parent = panel,
ImageIndex = group.ImageIndex,
Tag = group,
ImageList = lstGlyph32,
FlatStyle = FlatStyle.Flat,
Text = " ...",
ImageAlign = ContentAlignment.MiddleLeft,
TextAlign = ContentAlignment.MiddleRight
};
buttonToolTip.SetToolTip(groupBtn, group.Title);
groupBtn.SetBounds(left, buttonTop, groupBtnWidth, buttonSize.Height);
left += (groupBtn.Width + buttonMarging);
// создать менюшку
groupBtn.Click += GroupBtnClick;
var btnMenu = new ContextMenuStrip {/*Parent = this,*/ Tag = group.Title};
var thisGroup = group;
var groupButtons = buttons.Where(b => b.Group == thisGroup);
foreach (var btn in groupButtons)
{
var item = new ToolStripButton(btn.ToString(), lstGlyph32.Images[btn.Image],
ToolStripBtnClick) {Tag = btn};
btnMenu.Items.Add(item);
if (btnMenu.Width < item.Width)
btnMenu.Width = item.Width;
}
// добавить пустышку, чтобы размер меню был посчитан корректно
if (btnMenu.Items.Count == 1)
{
var item = new ToolStripLabel("empty") {Visible = false};
btnMenu.Items.Add(item);
}
buttonMenus.Add(btnMenu);
//.........这里部分代码省略.........