linux怎么查看本机内存大小
183
2022-11-15
C#上机实验
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;using System.IO;namespace chap4_随堂测试编程{ public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void checkBox1_CheckedChanged(object sender, EventArgs e) { button2.Enabled = checkBox1.Checked;//实现checkedbox1按钮可用的时候,勾选注册按钮可用,否则不可用。 //if (checkBox1.Checked == true) // button2.Enabled = true; //else // button2.Enabled = false; } private void timer1_Tick(object sender, EventArgs e)//每隔100秒递增一个值,当达到最大值时,使得timer1不可用,同时将textbox的text添加到listbox的列表中。 { progressBar1.Value += progressBar1.Step; if (progressBar1.Value == progressBar1.Maximum) { timer1.Enabled = false; listBox1.Items.Add(textBox1.Text); } } private void button1_Click(object sender, EventArgs e) { //openFileDialog1.Filter = "jpg文件|*.jpg|gif文件|*.gif"; //if (openFileDialog1.ShowDialog() == DialogResult.OK) // textBox3.Text = openFileDialog1.FileName; openFileDialog1.Filter = "jpg文件|*.jpg|gif文件|*.gif"; if (openFileDialog1.ShowDialog() == DialogResult.OK) textBox3.Text = openFileDialog1.FileName; } private void button2_Click(object sender, EventArgs e) { } private void button3_Click(object sender, EventArgs e) { } }}
MessageBox.Show()的方法:
运用消息对话框的例子:
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 button1_Click(object sender, EventArgs e) { DialogResult dr;//定义对象。 dr = MessageBox.Show("测试一下你的对话框!", "测试测试测试!", MessageBoxButtons.YesNoCancel,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1); if(dr==DialogResult.Yes) MessageBox.Show("你选择的为“是”按钮","系统提示1"); else if(dr==DialogResult.No) MessageBox.Show("你选择的为“否”按钮","系统提示2"); else if(dr==DialogResult.Cancel) MessageBox.Show("你选择的为“取消”按钮","系统提示3"); else MessageBox.Show("你没有进行任何操作!","系统提示4"); } }}
打开文件对话框:
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;using System.IO;namespace 茶品特然{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { DialogResult dr;//定义对象。 dr = MessageBox.Show("测试一下你的对话框!", "测试测试测试!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); if (dr == DialogResult.Yes) MessageBox.Show("你选择的为“是”按钮", "系统提示1"); else if (dr == DialogResult.No) MessageBox.Show("你选择的为“否”按钮", "系统提示2"); else if (dr == DialogResult.Cancel) MessageBox.Show("你选择的为“取消”按钮", "系统提示3"); else MessageBox.Show("你没有进行任何操作!", "系统提示4"); } private void button2_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = "D:\\"; openFileDialog.Filter = "文本文件|*.*|c#文件|*.cs|所有文件|*.*"; openFileDialog.RestoreDirectory = true; openFileDialog.FilterIndex = 1; if(openFileDialog.ShowDialog()==DialogResult.OK) { string fname=openFileDialog.FileName; //StreamReader sr = File.OpenText(fname);//这里会打开乱码,可能是编码不对。 StreamReader sr = new StreamReader(fname, Encoding.Default); string str; while((str=sr.ReadLine())!=null) { this.richTextBox1.Text+=str; } } } }}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~