vb.net 怎么建立类似office 记事本那样的查询功能?

wuyalang2009 2009-12-04 09:38:00
vb.net 怎么建立类似office 记事本那样的查询功能?

类似这样

点了后可以在当前的datagridview里查询 关键字,并选中关键字。若有多个 则可以提示让你选择
...全文
91 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
standhong 2009-12-04
  • 打赏
  • 举报
回复
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 TxT
{
public partial class chazhao : Form
{
public chazhao()
{
InitializeComponent();
}

public RichTextBox rtb;
int start = 0;//查找的起始位置
string str = "";//查找的内容
RichTextBoxFinds f;
private void button1_Click(object sender, EventArgs e)
{
str = this.textBox1.Text;
//查找
start = rtb.Find(str, start, f);
if (start == -1)
{
MessageBox.Show("对不起!查找不到与“" + str + "”相符的内容!", "(记事本 V1.0 Beta)查找提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
start = 0;
}
else
{
start = start + str.Length;//找到后从找到位置之后开始下一次
rtb.Focus(); //给予焦点
}
}
private void button1_Click(object sender,EventArgs e)
{
str = this.textBox1.Text;
start = rtb.Find(str, start, f);
if (start == -1)
{
MessageBox.Show("");
}
else
{
start = start + str.Length;
rtb.Focus();
}

}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (this.checkBox1.Checked == false)
f = RichTextBoxFinds.None;
else
f = RichTextBoxFinds.MatchCase;
}

private void button2_Click(object sender, EventArgs e)
{
this.Close();
}

private void chazhao_Load(object sender, EventArgs e)
{

}
}
}

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧