1与2全有了。ListView . using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace ListViewDemo
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.ImageList imageList2;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.ComponentModel.IContainer components; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace ListViewDemo
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.ImageList imageList2;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.ComponentModel.IContainer components; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
解决方案 »
- 讨论C#委托、事件、泛型
- 此行已从表中移除并且没有任何数据。BeginEdit() 将允许在此行中创建新数据
- insert into语句的语法错误问题!
- 求高手 在线等 往 textarea 里面输入数据 输出时候没有换行
- 在使用DevExpress.XtraGrid.GridControl中怎样按数据值的宽度自动设置字段宽度.
- 请问用web service返回较大数据量的DataSet快,还是用Remoting返回的速度快。
- 如何把 Hello.cx类生成 Hello.dll类库?解决了马上给分
- [急!100分]如何用C#写绘图代码,请高手帮帮忙啊
- 请问这是怎么回事?
- 怎样在MultiLine的TextBox使用Ctrl-A来全选?
- 求助
- 请问怎样从一个aspx页面将数据post到另一个aspx页面?解决就给分
this.button1.Location = new System.Drawing.Point(240, 248);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(72, 24);
this.button1.TabIndex = 7;
this.button1.Text = "添加";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(240, 305);
this.button2.Name = "button2";
this.button2.TabIndex = 8;
this.button2.Text = "删除";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label4
//
this.label4.Location = new System.Drawing.Point(360, 256);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(80, 16);
this.label4.TabIndex = 9;
this.label4.Text = "视图模式";
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.Items.AddRange(new object[] {
"大图标",
"小图标",
"列表",
"详细资料"});
this.comboBox1.Location = new System.Drawing.Point(360, 272);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(120, 20);
this.comboBox1.TabIndex = 10;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(544, 349);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label4);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.listView1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.Text = "通讯录";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void button1_Click(object sender, System.EventArgs e)
{
//获得ListView当前包含的条目数目
int itemsNumber=listView1.Items.Count; //构造条目的子条目字符串数组
String[] subItems =new string[]
{
textBox1.Text,
textBox2.Text,
textBox3.Text
};
//插入新的条目
listView1.Items.Insert(itemsNumber,new ListViewItem(subItems));
listView1.Items[itemsNumber].ImageIndex=0; } private void button2_Click(object sender, System.EventArgs e)
{
//循环语句
for (int i=listView1.SelectedItems.Count -1;i>=0;i--)
{
//获取当前选中的条目之一
ListViewItem li=listView1.SelectedItems[i];
//删除这个条目
listView1.Items.Remove( li);
}
} private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
string selectedStr=comboBox1.SelectedItem.ToString();
switch(selectedStr)
{
//大图标视图
case "大图标":
listView1.View=View.LargeIcon;
break;
//以小视图显示
case "小图标":
listView1.View=View.SmallIcon;
break;
//列表视图
case "列表":
listView1.View=View.List;
break;
//详细资料
case "详细资料":
listView1.View=View.Details;
break;
}
} private void Form1_Load(object sender, System.EventArgs e)
{
} }
}
MessageBox.Show("Welcome!","Message",MessageBoxButtons.YesNo,MessageBoxIcon.Information);
using namespace Microsoft::win32; Registry类只有七个字段成员,使得你能够存取注册编辑表中七个特定的键,这同你在注册编辑表中打开一个键非常类似,这些所有的成员均返回一个指向注册键的指针。 ClassesRoot 对应于HKEY_CLASSES_ROOT
CurrentConfig 对应于HKEY_CURRENT_CONFIG
CurrentUser 对应于HKEY_CURRENT_USER
DynData 对应于HKEY_DYN_DATA
LocalMachine 对应于HKEY_LOCAL_MACHINE
PerformanceData 对应于HKEY_PERFORMANCE_DATA
Users 对应于HKEY_USERS 比如你想读写HKEY_LOCAL_MACHINE的数据,你可以先获得一个指向该键的指针。 RegistryKey* pRegKey = Registry::LocalMachine; 接着调用RegistryKey的OpenSubKey成员函数,然后再调用GetValue即可获得一个特定的字符串。 pRegKey->OpenSubKey(L"SOFTWARE\\Kruse Inc\\Version");
Object *pValue = pRegKey->GetValue(L"kWise"); 如果你想设置一个键的值,则需要调用它的SetValue函数。 pRegKey->SetValue(L"kWise", "some Value Here"); 删除一个值可以使用: pRegKey->DeleteValue(L"kWise"); 其它常用的成员函数还有: DeleteSubKey 删除一个子键
CreateSubKey 如果键已经存在就打开该键,否则就创建新键
DeleteSubKeyTree 删除子键及其节点 下面是程序代码例子(Microsoft Visual c++.net beta2调试通过): #using
using namespace System;
using namespace Microsoft::Win32;
// 这是应用程序的入口点
int main(void)
{
RegistryKey * pRegKey = Registry::LocalMachine;
pRegKey = pRegKey->OpenSubKey(L"HARDWARE\\DESCRIPTION
\\System\\CentralProcessor\\0");
Object *pValue = pRegKey->GetValue(L"VendorIdentifier");
Console::WriteLine(L"本机的CPU为: {0}.", pValue);
return 0;
}
http://www.yesky.com/20011102/203269.shtml