C#常用控件操作大全
来源:互联网 发布:淘宝卖家如何退保证金 编辑:程序博客网 时间:2024/05/16 14:28
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 练习
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
textBox1.ReadOnly = false;
textBox1.Text += "不是只读属性";
textBox1.Text += " ";
textBox1.Text += "我是textBox控件";
textBox2.Text += "";
richTextBox1.Multiline = true;
// richTextBox1.SelectionBullet = true;
richTextBox1.Text += "http://blog.csdn.net/sun307146966?viewmode=contents ";
richTextBox1.ScrollBars = RichTextBoxScrollBars.Both;
richTextBox1.Text += "我是richTextBox控件";
comboBox1.DropDownStyle = ComboBoxStyle.DropDown;
comboBox1.Items.Add("我是ComboBox");
comboBox1.Items.Add("1");
comboBox1.Items.Add("2");
comboBox1.Items.Add("3");
comboBox1.Items.Add("4");
comboBox1.Items.Add("5");
comboBox1.Items.Add("6");
radioButton1.Checked = false;
radioButton2.Checked = false;
numericUpDown1.Maximum = 100;
numericUpDown1.Minimum = 0;
listBox1.HorizontalScrollbar = true;
listBox1.ScrollAlwaysVisible = true;
listBox1.SelectionMode = SelectionMode.MultiExtended;
groupBox1.Text = "分组控件";
panel1.Visible = true;
//richTextBox1.Text
//tabControl1.ImageList = imageList1;
//tabPage1.ImageIndex = 0;
tabPage1.Text = "选项卡1";
//tabPage2.ImageIndex = 0;
tabPage2.Text = "选项卡2";
tabControl1.Appearance = TabAppearance.Normal;
tabPage1.Controls.Add(new Button());
TabPage myTable = new TabPage("Title");
tabControl1.TabPages.Add(myTable);
this.toolStripStatusLabel1.Text = DateTime.Now.ToString();
}
private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(e.LinkText);
}
private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
{
textBox1.Text += "comboBox1的值是:" + comboBox1.Text;
}
private void checkBox1_Click(object sender, EventArgs e)
{
if (checkBox1.CheckState == CheckState.Checked)
{
MessageBox.Show("CheckBox被选中");
}
else
{
MessageBox.Show("CheckBox被取消");
}
}
private void radioButton1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked == true)
{
MessageBox.Show("radioButton1被选中");
}
}
private void radioButton2_Click(object sender, EventArgs e)
{
if (radioButton2.Checked == true)
{
MessageBox.Show("radioButton2被选中");
}
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
textBox1.Text += "numericUpDown1的值是:" + numericUpDown1.Value;
}
private void button1_Click(object sender, EventArgs e)
{
TextBox myText = new TextBox();
myText.Location = new Point(25, 25);
myText.Text = "LV";
this.Controls.Add(myText);
MessageBox.Show("123456");
if (textBox1.Text == "")
{
MessageBox.Show("不能为空");
}
else
{
listBox1.Items.Add(textBox1.Text);
textBox1.Text = "";
}
if (textBox2.Text == "")
{
MessageBox.Show("输入姓名:");
textBox2.Focus();
}
else
{
if (textBox2.Text == "LV")
{
textBox3.Text += "姓名:LV";
textBox3.Text += " 身高:163 ";
textBox3.Text += "体重:40kg";
panel1.Show();
}
else
{
MessageBox.Show("查无此人");
textBox2.Text = "";
}
}
}
private void button2_Click(object sender, EventArgs e)
{
if (listBox1.SelectedItems.Count==0)
{
MessageBox.Show("请选择删除选项");
}
else
{
listBox1.Items.Remove(listBox1.SelectedItem);
}
if (tabControl1.SelectedIndex == 0)
{
MessageBox.Show("请选择删除选项卡");
}
else
{
tabControl1.TabPages.Remove(tabControl1.SelectedTab);
}
}
private void button3_Click(object sender, EventArgs e)
{
this.toolStripProgressBar1.Minimum = 0;
this.toolStripProgressBar1.Maximum = 100;
this.toolStripProgressBar1.Step = 1;
for (int i = 0; i < 100; i++)
{
this.toolStripProgressBar1.PerformStep();
}
}
}
}
- C#常用控件操作大全
- C#控件 常用操作
- [WinForm]WinForm跨线程UI操作常用控件类大全
- vs2005常用控件大全
- vs2005常用控件大全
- VS2010常用控件大全
- C#控件大全
- C#控件大全
- 日期控件操作大全
- SQL常用操作大全
- MATLAB常用操作大全
- c#数据库操作大全
- C#注册表操作大全
- C#文件操作大全
- C#文件操作大全
- C#文件操作大全
- C#文件操作大全
- C#文件操作大全
- LAN9221网卡驱动之二 NAPI接收
- VS2010自定义消息
- 2011年企业软件行业回顾和发展
- 《TCP/IP协议》第三章 IP:网际协议
- Qlikview+nPrinting
- C#常用控件操作大全
- 23种设计模式(4):建造者模式
- jQuery源码分析-extend函数
- QLineEdit输入检查 hasacceptableinput
- 百分点推荐引擎——从需求到架构
- 23种设计模式(5):原型模式
- Spring笔记整理——对象
- 创建类模式总结篇
- 谁是你心目中最优秀的ajax框架