窗体控件的使用

3.1~3.1

菜单栏:menuStrip;

状态栏的显示:this.toolStripStatusLabel1.Text = "大窗体";

背景色设置:this.BackColor=Color.Red;

位置设置:label1.Location = new Point(92, 50);  textbox1.Location=new Point(92,50);

 问题:光标变化:this.toolStripButton2 = Cursors.Default;    提示错误。

更改图标设置:将图标文件复制到项目文件下bin/Degug中,this.Icon = new Icon("你的 ICON 路径");

this.BackColor = Color.FromArgb(hScrollBar1.Value, hScrollBar2.Value, hScrollBar3.Value);//FromArgb(三原色的值);

this.ForeColor = Color.FromArgb(hScrollBar1.Value, hScrollBar2.Value, hScrollBar3.Value);设置控件前景色。

this.Opacity = 0.5 + (double)trackBar1.Value / 100;设置窗体透明度,如果没有(double)强制转换就无法调节透明度。

 comboBox1.SelectedIndex = 0;显示comboBox1中添加的项,Selectedindex=0为第一项,以此类推。

遇到的问题:

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
comboBox1.SelectedIndex = 1;
numericUpDown1.Value = 2;
}

private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
if (numericUpDown1.Value == 1)
radioButton1.Checked = true;
else if (numericUpDown1.Value == 2)
radioButton2.Checked = true;
else
radioButton3.Checked = true;
}   两个一起写会出错

 解决:

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked == true)
{
    comboBox1.SelectedIndex = 1;
    numericUpDown1.Value = 2;
}
}

原文地址:https://www.cnblogs.com/-sbz/p/7587118.html