using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace _034
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
lbox_str.Items.AddRange(G_str_array);//将数组元素罗列在listbox空间中,将现有的项添加到listbox1中;
}
string[] G_str_array = new string[]
{
"C#范例宝典",
"C#编程宝典",
"C#视频学",
"C#项目开发全程实录",
"C#项目开发实例自学手册",
"C#编程词典",
"C#实战宝典",
"C#经验技巧宝典",
"C#入门模式"
};
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
// lbox_str.Items.AddRange(G_str_array);
}
private void bt_query_Click(object sender, EventArgs e)
{
int i = 0;
label1:
if(G_str_array[i].Contains(textbox.Text))
{
lbox_str.SelectedIndex = i;
MessageBox.Show(textbox.Text + "已经找到", "提示");
return;
}
i++;
if (i < G_str_array.Length) goto label1;
MessageBox.Show(textbox.Text + "没有找到","提示");
}
private void txt_query_TextChanged(object sender, EventArgs e)
{
}
}
}