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 6934799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:00:31+00:00 2026-05-27T12:00:31+00:00

I am using Windows form and C# and MySQL. In that i add three

  • 0

I am using Windows form and C# and MySQL.

In that i add three unbound columns in Datagridview with the help of control tag witch is in Datagridview right top.

column1 is DataGridViewCheckBoxColumn.
column 2 and 3 is DataGridViewTextBoxColumn.

After that i wrote code to fill the Datagrid view.

connection.Open();
                 DataTable dt = new DataTable();
                 // Create a new data adapter based on the specified query.
                 MySqlDataAdapter da = new MySqlDataAdapter("select admin_no,name from " + FormName + " where class_code='" + class_code + "' and division_code='" + division_code + "' and Delete_Status = 0", connection);
                 //SQl command builder is used to get data from database based on query
                 MySqlCommandBuilder cmd = new MySqlCommandBuilder(da);
                 //Fill data table
                 da.Fill(dt);
                 //assigning data table to Datagridview
                 dataGridView1.DataSource = dt;
                 //Resize the Datagridview column to fit the gridview columns with data in datagridview
                 dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
                 connection.Close();

In That I got

enter image description here

Here u see the two columns of Textbox is empty. and other two is added.

I don’t want to remove the textbox. So I want to populate the data with in my textbox, not a auto generated one.,..

Please help me, to solve this problem….

Thanks, I got the value in template Textbox columns. But the Last two columns of auto generated columns are added. How to remove that.

connection.Open();
                 DataTable dt = new DataTable();                 
                 MySqlDataAdapter da = new MySqlDataAdapter("select admin_no,name from " + FormName + " where class_code='" + class_code + "' and division_code='" + division_code + "' and Delete_Status = 0", connection);                 
                 MySqlCommandBuilder cmd = new MySqlCommandBuilder(da);                 
                 da.Fill(dt);                 
                 dataGridView1.DataSource = dt;                                 
                 dataGridView1.Columns[1].DataPropertyName = "admin_no";
                 dataGridView1.Columns[2].DataPropertyName = "name";
                 connection.Close();

enter image description here

Help Me again Please.

Sorry i forgot “dataGridView1.AutoGenerateColumns = false;”.

Thanks I got my requirement.

  • 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-27T12:00:32+00:00Added an answer on May 27, 2026 at 12:00 pm

    You have to set DataGridViewTextBoxColumn.DataPropertyName="name_of_field". Take a look at MSDN article.

    PS: You should have to use Parameterized query instead of hard-coded sql string to prevent sql-injection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Windows Form and MySQL for my project. In that i want
I have a program where I am using windows form, in that form I
I am using windows form and mysql. I am very confuse about different between
I have a windows form control inside wpf application using a windows forms host.
When using the System.Windows.Forms.TableLayoutPanel control on a windows form, it sets the background color
I am trying to draw a circle using Windows Form at runtime inside a
If i were developing a screensaver using a windows.form in C# how would i
Im using c# .net windows form application. i have a SQL database with 5
Im using c# .net windows form application. I have many databases created using sql
Im using c# .net windows form application. I have loaded names of all the

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.