问题:
利用三个控件Textbox1 botton1 listview1 实现在文本框里输入相应内容,按botton键,在listview中显示出来,希望能有必要的代码,谢谢~~
利用三个控件Textbox1 botton1 listview1 实现在文本框里输入相应内容,按botton键,在listview中显示出来,希望能有必要的代码,谢谢~~
解决方案 »
- DATAGIRDVIEW中手动添加CHECKBOX的问题
- 打开网页的同时直接触动登陆按钮
- 窗口传值并且返回一个DATAGRIDVIEW的值
- 根据title得到控件的值
- 在线== 怎样在datagrid控件中添加一列,并在列中可以添加按扭控件
- 电脑蓝屏了,哪位高手帮忙看一下
- 如何根据异常快照的信息调试程序
- Push模式下的水晶报表,为什么总是空白的报表?dataset填充到.rpt文件,在.rpt文件中需要拉字段出来吗?
- 如何合并两个dataset
- C#上位机读取CAN总线上数据
- 这样的字符串如何实现替换
- 如何给 private void timer1_Tick(object sender, EventArgs e)建个独立线程?
UP
listView1.Items.Add("List item text", 3);
{
this.listView1.Items.Add(this.textBox1.Text);
}
{
listView1.Items.Add(textBox1.Text);
}
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace Test
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.ColumnHeader ColunmHeader1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.listView1 = new System.Windows.Forms.ListView();
this.ColunmHeader1 = new System.Windows.Forms.ColumnHeader();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(24, 96);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(16, 12);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 2;
this.textBox1.Text = "textBox1";
//
// listView1
//
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.ColunmHeader1});
this.listView1.GridLines = true;
this.listView1.Location = new System.Drawing.Point(130, 12);
this.listView1.Name = "listView1";
this.listView1.TabIndex = 3;
this.listView1.View = System.Windows.Forms.View.Details;
//
// ColunmHeader1
//
this.ColunmHeader1.Text = "文本框内容";
this.ColunmHeader1.Width = 98;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.listView1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void button1_Click(object sender, System.EventArgs e)
{
if (textBox1.Text!="")
{
string[] subItem={textBox1.Text};
//lstUserInfo.Items.Insert(itemNumber,new ListViewItem(subItem6));
listView1.Items.Add(new ListViewItem(subItem));
}
}
}
}
listView1.Items.Add(new ListViewItem(subItem));
{
if (this.tbSearch.Text == "") return;
this.cbbSearch.Items.Clear();
odCmd.CommandText = string.Format("SELECT SightName FROM {0} WHERE Re Like '%{1}%'", this.tbTable.Text, this.tbSearch.Text.Trim());
OleDbDataReader oddr = odCmd.ExecuteReader();
while (oddr.Read())
{
string sType = oddr.GetString(0);
this.cbbSearch.Items.Add(sType);
}
oddr.Close();
if (this.cbbSearch.Items.Count > 0) this.cbbSearch.SelectedIndex = 0;
} private void cbbSearch_SelectedIndexChanged(object sender, EventArgs e) {
odCmd.CommandText = string.Format("SELECT * FROM {0} WHERE Re LIKE '%{1}%' AND SightName = '{2}'", this.tbTable.Text, this.tbSearch.Text.Trim(), this.cbbSearch.SelectedItem.ToString());
this.GetReaderContents();
}
我是要把数据库里的同一属性的数据显示在listview中,我模仿上面的comboBox例子,可是写出来的总出错啊,哪们大虾帮帮我啊,问题解决就结帖,不想占用大家太多时间