C#初学者,谁能提供一些简单的代码,小程序等??? C#初学者,谁能提供一些简单的代码,小程序等??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在http://download.csdn.net/很多可下载 小程序/窗体传值窗体1又一个listbox和一个按钮using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Collections;namespace Mytest{ public partial class Form1 : Form { ArrayList arraylist; public Form1() { InitializeComponent(); arraylist = new ArrayList(); arraylist.Add("aa"); arraylist.Add("bb"); arraylist.Add("vv"); arraylist.Add("cc"); listBox1.DataSource = arraylist; } private void button1_Click(object sender, EventArgs e) { Form2 f2 = new Form2(arraylist); f2.ShowDialog(); listBox1.DataSource = null; listBox1.DataSource = arraylist; } private void Form1_Load(object sender, EventArgs e) { } }}窗体2有一个listbox和按钮1按钮2按钮3using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Collections;namespace Mytest{ public partial class Form2 : Form { ArrayList arraylist2; public Form2(ArrayList arraylist3) { InitializeComponent(); arraylist2 = new ArrayList(); arraylist2 = arraylist3; foreach (object obj in arraylist2) { listBox1.Items.Add(obj); } } private void Form2_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Length > 0) { arraylist2.Add(textBox1.Text); listBox1.Items.Add(textBox1.Text); } else MessageBox.Show("error"); } private void button2_Click(object sender, EventArgs e) { int i = listBox1.SelectedIndex; if (i > -1) { arraylist2.RemoveAt(i); ; listBox1.Items.RemoveAt(i); } else MessageBox.Show("error"); } private void button3_Click(object sender, EventArgs e) { this.Close(); } }} 一道面试题,是题难还是人不行呢? 求指点,不胜感激! 请教一个C#卸载的问题 C# 窗体图片太多 运行就狂闪的问题 问大侠们几个比较菜的问题,是关于多线程的(酷似迅雷) 下拉框绑定数据库内的值怎样达到如下效果? 如何可以高效的将一个datatable的记录更新到另一个datatable中 C#怎样将Sql server中的图片保存到硬盘上? 如何能够实现在系统中只开一个程序 急!!谢谢 请高手指条明路 在DatagridView中的单元格中有没有办法多行显示信息 如何将拖到容器控件上的控件的父对象设置为容器控件中的子控件 求教,在线等~~~ C# winform
窗体1又一个listbox和一个按钮
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;namespace Mytest
{
public partial class Form1 : Form
{
ArrayList arraylist;
public Form1()
{
InitializeComponent();
arraylist = new ArrayList();
arraylist.Add("aa");
arraylist.Add("bb");
arraylist.Add("vv");
arraylist.Add("cc");
listBox1.DataSource = arraylist;
} private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2(arraylist);
f2.ShowDialog();
listBox1.DataSource = null;
listBox1.DataSource = arraylist;
} private void Form1_Load(object sender, EventArgs e)
{ }
}
}
窗体2有一个listbox和按钮1按钮2按钮3
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;namespace Mytest
{
public partial class Form2 : Form
{
ArrayList arraylist2;
public Form2(ArrayList arraylist3)
{
InitializeComponent();
arraylist2 = new ArrayList();
arraylist2 = arraylist3;
foreach (object obj in arraylist2)
{
listBox1.Items.Add(obj);
}
} private void Form2_Load(object sender, EventArgs e)
{ } private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length > 0)
{
arraylist2.Add(textBox1.Text);
listBox1.Items.Add(textBox1.Text);
}
else
MessageBox.Show("error");
} private void button2_Click(object sender, EventArgs e)
{
int i = listBox1.SelectedIndex;
if (i > -1)
{
arraylist2.RemoveAt(i); ;
listBox1.Items.RemoveAt(i);
}
else
MessageBox.Show("error");
} private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
}
}