Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8323759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:49:18+00:00 2026-06-08T23:49:18+00:00

Using Windows forms and linq to Sql, I bound a datagridview to Products Table,

  • 0

Using Windows forms and linq to Sql, I bound a datagridview to Products Table, I added to the form 1 Textbox to input the searched text.
I wonder how to position the datagridview according to the text entered to find a given ProductName.
Here I do not want to filter rows, I only want to reposition datagrid after each character entered, the used code:

    private void textBox1_TextChanged(object sender, EventArgs e)
    {
        var searchValue = textBox1.Text.Trim().ToUpper();
        var qry = (from p in dc.Products
                   where p.ProductName.ToUpper().StartsWith(searchValue)
                   select p).ToList();
        int itemFound = productBindingSource.Find("ProductName", searchValue);
        productBindingSource.Position = itemFound;
    }

The execution of code give the next error: System.NotSupportedException was unhandled at the ligne:

int itemFound = productBindingSource.Find("ProductName", searchValue);

Any idea please ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T23:49:19+00:00Added an answer on June 8, 2026 at 11:49 pm

    The MSDN documentation for BindingSource has the answer:

    The Find method can only be used when the underlying list is an
    IBindingList with searching implemented. This method simply refers the
    request to the underlying list’s IBindingList.Find method. For
    example, if the underlying data source is a DataSet, DataTable, or
    DataView, this method converts propertyName to a PropertyDescriptor
    and calls the IBindingList.Find method. The behavior of Find, such as
    the value returned if no matching item is found, depends on the
    implementation of the method in the underlying list.

    When you call this method on a BindingSource whose underlying data source does not implement IBindingList then you see the exception (thrown by the default implementation of IBindingList.FindCore:

    System.NotSupportedException: The specified method is not supported.

    You don’t show what you bind the binding source to but clearly it doesn’t implement this method.

    Annoyingly, BindingList<T> the recommended list type to use for your data source does not provide a FindCore implementation.

    If you are using BindingList you will need to create your own custom type. Here is the code for an absolutely bare bones implementation of a BindingList that supports find:

    public class FindableBindingList<T> : BindingList<T>
    {
    
        public FindableBindingList()
            : base()
        {
        }
    
        public FindableBindingList(List<T> list)
            : base(list)
        {
        }
    
        protected override int FindCore(PropertyDescriptor property, object key)
        {
            for (int i = 0; i < Count; i++)
            {
                T item = this[i];
                if (property.GetValue(item).Equals(key))
                {
                    return i;
                }
            }
            return -1; // Not found
    
        }
    }
    

    You can do lots with your own implementations of BindingList such as supporting sorting. I’ve left my answer as just the minimum to support the find method. Search for SortableBindingList if you want to know more.


    To use this class do something like this:

    var qry = (from p in dc.Products
                   where p.ProductName.ToUpper().StartsWith(searchValue)
                   select p).ToList();    
    
    FindableBindingList<YourType> list = new FindableBindingList<YourType>(qry);
    
    dataGridView1.DataSource = list;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're developing a .NET 3.5 Windows Forms app, using LINQ to SQL and MVP.
We're developing a C# Windows Forms application, using LINQ-to-sql, databindding and the Error provider
Iam using windows forms. How can I query all child controls of a Form
I'm trying to change the border style of my form using Windows Forms. The
I've got Windows Forms project. There's a textBox on the form, called txt. The
I have defined the following classes and methods: using System; using System.Linq.Expressions; using System.Windows.Forms;
Creating My Windows Form Application and using ADO.Net as Data Access layer and SQL
I have a C# project using windows forms. I need to let the user
I have an f# script using Windows Forms and I want it to run
I want to provide my colleagues with an interface (using Windows Forms or WPF)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.