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

  • SEARCH
  • Home
  • 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 6727147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:00:49+00:00 2026-05-26T10:00:49+00:00

My datagrid show a table from my sqlBd. I add a textBox for each

  • 0

My datagrid show a table from my sqlBd. I add a textBox for each column that for show each rows.

This is my code:

 private void CustomerViewToolStripMenuItem_Click(object sender, EventArgs e)
    {
        BindingSource Clients_bs = new BindingSource();
        SqlConnection con = new SqlConnection(dc.Con);
        con.Open();
        da.SelectCommand = new SqlCommand("SELECT * FROM Clients", con);

        da.Fill(dt);
        con.Close();

        dgCustomers.DataSource = dt;
        Clients_bs.DataSource = dt;

       txtBoxIdCustomers.DataBindings.Add(new Binding("Text", Clients_bs,"id_Client"));                

        txtBoxFullName.DataBindings.Add(new Binding("Text", Clients_bs, "prénom_Nom"));
        txtBoxAddress.DataBindings.Add(new Binding("Text", Clients_bs, "adresse"));
        txtBoxCity.DataBindings.Add(new Binding("Text", Clients_bs, "ville"));
        txtBoxProvince.DataBindings.Add(new Binding("Text", Clients_bs, "province"));
        txtBoxPostal.DataBindings.Add(new Binding("Text", Clients_bs, "code_Postal"));
        txtBoxPhone.DataBindings.Add(new Binding("Text", Clients_bs, "numéro_Teléphone"));
    }   

That fill my dataGrid like my table in sql, and my txtbox’s shows the first row only whit the cursor pointing on the first row in my dataGrid.

I want to move the cursor of the data grid on the second row and show txtbox’s bind automatically on the second row ….

I can make whit a button previous and next, but not whit the cursor…

Thank’s for helping me!

  • 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-05-26T10:00:49+00:00Added an answer on May 26, 2026 at 10:00 am

    instead of this:

    dgCustomers.DataSource = dt;
    Clients_bs.DataSource = dt;
    

    do this:

    Clients_bs.DataSource = dt;
    dgCustomers.DataSource = Clients_bs;
    

    then it should work as the TextBoxes and the Grid have the same BindingSource 😉

    Edit:

    and also, please, instead of this:

    SqlConnection con = new SqlConnection(dc.Con);
    con.Open();
    da.SelectCommand = new SqlCommand("SELECT * FROM Clients", con);
    
    da.Fill(dt);
    con.Close();
    

    do this:

    using(var con = new SqlConnection(dc.Con))
    {
        con.Open();
        da.SelectCommand = new SqlCommand("SELECT * FROM Clients", con);
    
        da.Fill(dt);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to code a WPF 4.0 DataGrid that matches a database table, with
How can we Use a DataGrid in WPF to show/update/add/delete records in a Table?
I want to show datagrid content (rows,columns) in XPS document.I have 20 columns. When
I have a DataGrid that needs to show a gradient background on mouseover of
I have a DataGrid where each column has a SortExpression. I would like the
I'd really appreciate any help on this. There is this Dojox Datagrid that I'm
How can I show a join table in a datagrid in Flex using LCDS
I have a problem with enum description. I want that the dataGrid show me
I created an application to show a datagrid with a custom column in Flex
Can anybody show me how to fill DataGrid or any table like widget in

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.