本文介绍了在列表框中查找并显示项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 嗨所有 问题是我想用户在serch文本框中输入项目的名称,然后点击搜索按钮,当该项目查找显示时,告诉其他文本框中该名称的编号是我的代码 private void btAdd_Click( object sender,EventArgs e) { tbTell.Text = tbTell.Text.ToString(); tbName.Text + = | + tbFamily.Text; listnames.Items.Add(tbName.Text + | + tbTell.Text); string number = tbTell.Text; tbName.Text = ; tbName.Focus(); } private void btnSerch_Click( object sender,EventArgs e) { listnames.FindString(tbSerch.Text); } 但此代码不适用于搜索 但是工作是为了在列表中的1项中添加姓氏和电话号码的名称 我尝试了什么: i尝试使用查找字符串函数 试图为自己编写一个函数 但没有任何效果但解决方案 你的ListBox如下所示: listnames.Items.Add(tbName.Text + | + tbTell.Text); 您对搜索结果一无所知: listnames.FindString(tbSerch.Text); 这是一个Google搜索,其中包含如何执行所需操作的示例: winform listbox text search [ ^ hi allquestion is i want to user put name of the item in serch textbox and then click on search button and when that item finded show tell number of that name in an other textbox here is my codeprivate void btAdd_Click(object sender, EventArgs e){ tbTell.Text = tbTell.Text.ToString(); tbName.Text += " | " + tbFamily.Text; listnames.Items.Add(tbName.Text+" | "+tbTell.Text); string number = tbTell.Text; tbName.Text = ""; tbName.Focus();}private void btnSerch_Click(object sender, EventArgs e){ listnames.FindString(tbSerch.Text);}but this code is not working for searchbut working for add a name with last name and phone number in 1 item in the listWhat I have tried:i tried to use find string functiontried to write a function for myselfbut nothing worked yet 解决方案Your ListBox looks like this:listnames.Items.Add(tbName.Text+" | "+tbTell.Text);And you are doing nothing with your search results:listnames.FindString(tbSerch.Text);Here is a Google Search with examples of how to do what you want: winform listbox text search[^] 这篇关于在列表框中查找并显示项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-14 23:24