.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to search a bound ListBox from a TextBox

Posted By:      Posted Date: October 13, 2010    Points: 0   Category :WPF


I am just starting out with WPF and so please pardon me if I ask very ignorant questions but I'm finding WPF quite an up-hill struggle! 

I have created a fairly simple app that has a Listbox to the left that is bound to a DataTable to an OLEDB datasource. Above this Listbox there is a Textbox. What I am trying to do is use the Texbox as search/filter on the bound Listbox. Currently I can click inside the Listbox and start typing and it works perfectly well in finding the most appropriate Item with the IsTextSearchEnabled=True. I want to mimic this functionality but in the Textbox. Is this possible? Here is the xmal:

<Window x:Class="Test.WPF.BasicContactSearch1.ContactWindow"
    Title="Contact Window" Height="480" Width="640"
    xmlns:local="clr-namespace:Test.WPF.BasicContactSearch1" Loaded="Window_Loaded">
  <DockPanel Width="auto" Height="auto" Margin="8 8 8 8">
    <Border Height="56" HorizontalAlignment="Stretch" VerticalAlignment="Top" BorderThickness="1" CornerRadius="8" DockPanel.Dock="Top" Backgroun

View Complete Post

More Related Resource Links

How to take value of bound field of grid in a variable or in a textbox.


How to take value of bound field of grid in a variable or in a textbox.

 I m using this code in .aspx page for grid.

<asp:GridView ID="Grd_Mprocess" runat="server" AutoGenerateColumns="False"

                      Width="100%" AllowPaging="True"


                      AllowSorting="True" PageSize="5"  >

                 <RowStyle CssClass="odd" />


<asp:BoundField HeaderText="DOC_TYPE_PK" DataField="DOC_TYPE_PK"  Visible="true" >


  <asp:TemplateField HeaderText="DOC TYPE ID" Visible="true">  &nbs

Simple search TextBox in asp.net

The article Simple search TextBox in asp.net was added by miya2008 on Monday, August 09, 2010.

I create a simple search textbox in asp.net with the help of LIKE operator (SQL)Step 1 :- First we create a table in database:->create table textsearch(id int identity( 1,1),fname varchar(50),lname varchar(50))Step 2:- In aspx page,I use the following

search textbox with search keyword inside?



how to make a search txtbox that includes the search keyword and when the user clicks the search keyword disappears

thanks for the help

search multiple words into textbox and populate all records in gridview related those keywords


I have a textbox and a gridview which is bound to a table

what I want to achieve is a solution where lets say there are two records - e.g. "1. Book and 2. Red", i want a user to type in those words and the gridview shows the results as followed;

1. Book

2. Red

I have set up the sql data source and everything and my like operator is this...

LIKE '%' + @record + '%'

how can I solve this problem?

Filter a listbox with textbox


So i currently filter the listbox with some javascript i have found.
What it does is going to the item i type on the textbox.
It will not filter the listbox so it will contain the specific matches.
I was reading for autocomplete but i don't seem to find this 2 way usage.
I was also reading this article:
But i'm completely lost on how i can implement it.
Any ideas?

gridview filtering using a codebehind (textbox + search button)

i am trying to replicate the following sequence: input text into text box > press search button > search a database using LIKE operator > display using a gridview or listview. this sequence is fairly easy to do using the drag and drop then sqldatasource options, but i am trying to do the same result using a codebehind.  here is my code:   ____________________________________________________________________________________________________________ SqlConnection myConn; myConn = new SqlConnection(@"Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\projectDB.mdf; Integrated Security=True;User Instance=True"); myConn.Open(); string strSQL; strSQL = "SELECT * FROM Message";       //strSQL = "SELECT * FROM Message WHERE Message LIKE '" + txtSearch.Text + "'"; SqlDataAdapter da = new SqlDataAdapter(strSQL, myConn); DataSet ds = new DataSet(); da.Fill(ds, "Message"); GridView1.DataSource = ds; GridView1.DataBind(); myConn.Close(); _____________________________________________________________________________________________________________  now, if I use this code inside a page_load event, it does work. if I put it inside a button_click event i get nothing. i am mystified by this.. any help? why can't i use a button to display my gridview1 when i'm using a code behind.  

How can i place windows textbox on taskbar like desktop search

Hi How can i place windows textbox on taskbar like desktop search thanks

Binding SharePoint Multiline textbox to a infopath repeating table Listbox

Hi, I have a InfoPath form  with repeating table control which gets the data from a sharepoint list. I'm trying to bind a multiline textbox to a listbox and intend to get the line by line data entered in the multiline textbox in sharepoint to show as same line by line in the form's listbox. or is there any other way of getting this done.  Thanks.

Make the AutoCompleteExtender more like the Netflix search textbox


I am using the autocompleteextender control in a project I am working on for a client, but I would like to be able to match words in the middle of the data I am searching. Controls such as the search textbox on sites like Netflix do this. For example, if I go to Netflix and search for 'wolfman' I get results like:

The Wolfman

The Real Wolfman

House of the Wolfman

With the extender I would only get results beginning with 'wolfman'. If my stored procedure in my webservice is written to do search the text as I want, nothing shows in the extender (I'm guessing because so many top results don't begin with the entered text). Is there a way to get the autocompleteextender to behave more like this?


I want to filter the gridview on textchange in search textbox....


hi friends...
i want to filter the gridview on textchange in search textbox....
if i press "a" the gridview should filled up with record starting with "a". i have some code

SqlDataSource1.SelectCommand = "select * from DeptMaster where DeptName like '" + TextBox1.Text + "%'";
        SqlDataSource1.SelectCommandType = SqlDataSourceCommandType.Text;
        GridView1.DataSource = SqlDataSource1;

its working while leaving the textbox but i want this code should execute on keypress event....

Bind An Already Bound TextBox to ComboBox SelectedItem


Hey all,


If I have a TextBox that is already two-way bound to something, but I also want it so when a ComboBox SelectedItem changes, then the TextBox's Text property is set to the new SelectedItem.


Here's what I have so far, I added the comment where the TextBox is, which I would like to also be bound to the ComboBox below this.


        <ListView Grid.Row="2" 
             DataContext="{Binding ScriptParameters}"

TextBox shows "old" value after being Coerced when bound to a Dependency Property




I am writing a WPF Custom Control.  I want to be able to limit the input for the DependancyProperty "Text".  I have the OnCoerce event handlers connected and this property is bound to the "Text" property on a TextBox in my content template as shown below:


Code Snippet

<TextBox Name="PART_txtEdit"

Background="{TemplateBinding Background}"

BorderBrush="{TemplateBinding BorderBrush}"

Hide Certain Row to Bound Listbox


I have a listbox that I want to check to see if the current row value already exists in another listbox.  How can I hide/preven row from being added to listbox at databind/databound?  Thanks

Adding to a ListBox from a TextBox


I am taking a Web App Development course in college and apparently the book has a typo.  The teacher is unable to figure out what is wrong.  I will post the Markup and the CodeBehind.


                                    Last name <br />
                                    <asp:TextBox ID="memberLastName" runat="server" Width="185px" /><br />

                                    First name <br />
                                    <asp:TextBox ID="memberFirstName" runat="server" Width="185px" /><br />

                                    <asp:Button ID="add" runat="server" Text="Add" OnClick="add_Click" CausesValidation ="False" UseSubmitBehavior="False" />
                                    <asp:Button ID="remove" runat="server" Text="Remove" OnClick="remove_Click" CausesValidation ="False" UseSubmitBehavior="False" />
                                    <asp:ListBox ID="groupMembers" runat="server" Height="120px" Width="190px"></asp:ListBox>


text of two textbox in listbox


Hi all

i want to have a list box and two textbox and one check box in each item of my listbox and have two text box and one button in window then each time i click on button then text of textbox1 and textbox2 add to list box.

any one know about this?



Textbox Editable GridView in ASP.NET

This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.

Highlighting Rows with TextBox OnFocus

In another article I explained that how you can make the rows of the GridView control clickable and highlight them when they are clicked. In this article I will explain that how you can highlight the GridView rows when you focus on the TextBox which is contained inside the GridView control.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend