Флажок предназначен для двухвариантного выбора.
сумма значений выбранных флажков
Form1.cs
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Windows.Forms;
namespace
WindowsFormsApplication1 {
-
public
partial
class
Form1 : Form {
-
public
Form1() {
-
InitializeComponent();
-
}
-
private
void
button1_Click(
object
sender, EventArgs e) {
-
int
res = 0;
-
if
(checkBox1.Checked) {
-
res +=
int
.Parse(checkBox1.Text);
-
}
-
if
(checkBox2.Checked) {
-
res +=
int
.Parse(checkBox2.Text);
-
}
-
if
(checkBox3.Checked) {
-
res +=
int
.Parse(checkBox3.Text);
-
}
-
if
(checkBox4.Checked) {
-
res +=
int
.Parse(checkBox4.Text);
-
}
-
if
(checkBox5.Checked) {
-
res +=
int
.Parse(checkBox5.Text);
-
}
-
textBox1.Text = res.ToString();
-
}
-
}
}
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Windows.Forms;
namespace
WindowsFormsApplication1 {
-
public
partial
class
Form1 : Form {
-
public
Form1() {
-
InitializeComponent();
-
}
-
private
void
button1_Click(
object
sender, EventArgs e) {
-
int
res = 0;
-
if
(checkBox1.Checked) {
-
res +=
int
.Parse(checkBox1.Text);
-
}
-
if
(checkBox2.Checked) {
-
res +=
int
.Parse(checkBox2.Text);
-
}
-
if
(checkBox3.Checked) {
-
res +=
int
.Parse(checkBox3.Text);
-
}
-
if
(checkBox4.Checked) {
-
res +=
int
.Parse(checkBox4.Text);
-
}
-
if
(checkBox5.Checked) {
-
res +=
int
.Parse(checkBox5.Text);
-
}
-
textBox1.Text = res.ToString();
-
}
-
}
}
активация элемента
Form1.cs
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Windows.Forms;
namespace
WindowsFormsApplication1 {
-
public
partial
class
Form1 : Form {
-
public
Form1() {
-
InitializeComponent();
-
}
-
private
void
checkBox1_CheckedChanged(
object
sender, EventArgs e) {
-
if
(checkBox1.Checked) {
-
textBox1.ReadOnly =
false
;
-
}
-
else
{
-
textBox1.ReadOnly =
true
;
-
}
-
}
-
}
}
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Windows.Forms;
namespace
WindowsFormsApplication1 {
-
public
partial
class
Form1 : Form {
-
public
Form1() {
-
InitializeComponent();
-
}
-
private
void
checkBox1_CheckedChanged(
object
sender, EventArgs e) {
-
if
(checkBox1.Checked) {
-
textBox1.ReadOnly =
false
;
-
}
-
else
{
-
textBox1.ReadOnly =
true
;
-
}
-
}
-
}
}