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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:35:43+00:00 2026-05-15T14:35:43+00:00

Hey guys, I have an application that I want to display some data from

  • 0

Hey guys, I have an application that I want to display some data from a sql db in a DataGridView… I have the data displayed in the DataGridView now but here are my questions… How can I use custom header titles because I don’t want the SQL column titles to be used for the DataGridView column titles. Also, I want it so that when a user double-clicks on a row, it will open the filePath value from that row… I would also like to be able to specify the width of the columns. Here is how the tables are layed out.

SQL Table:
Row_ID (I don’t want displayed in grid), PartNumber, CMMNumber, CreatedOn, FilePath, RacfId, currTime

Data grid view desired format:
Part Number, CMM Number, Created On, Path, User ID, Viewed On

Current code — This gets the data (all, including Row_ID) and uses the sql column names as the names for the data grid view columns, it also just uses default column widths.

private void NewAlert_Load(object sender, EventArgs e)
        {
            string connString = "Server=FRXSQLDEV;Database=MyDB;User Id=ID;Password=Password;";

            string query = "SELECT * FROM CMMReports WHERE RacfId IS NULL;";

            SqlDataAdapter dAdapter = new SqlDataAdapter(query, connString);

            SqlCommandBuilder cBuilder = new SqlCommandBuilder(dAdapter);

            DataTable dTable = new DataTable();

            dAdapter.Fill(dTable);



            //BindingSource to sync DataTable and DataGridView
            BindingSource bSource = new BindingSource();

            //set the BindingSource DataSource
            bSource.DataSource = dTable;

            //set the DataGridView DataSource
            dgView.DataSource = bSource;

            dAdapter.Update(dTable);



        }
  • 1 1 Answer
  • 1 View
  • 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-15T14:35:44+00:00Added an answer on May 15, 2026 at 2:35 pm

    If you want to use Custom titles etc. First of all create a new datatable, and give the names. Be Careful about typeof()

    DataTable dt = new DataTable();
    
            dt.Columns.Add("Title 1",typeof(int));
            dt.Columns.Add("Title 2", typeof(string));
            dt.Columns.Add("Title 3", typeof(DateTime));
            dt.Columns.Add("Title 4", typeof(bool));
            dt.AcceptChanges();
    

    Get all data which comes from SQL and create object for them in

    foreach(var item in yourSqlData)

    object[] row = new object[] 
            { 
            item.data1.ToString(), // string columns
            Convert.ToInt32(item.data2), // int columns
            Convert.ToDateTime(item.data3), // datetime column
            Convert.ToBoolean(item.data4) // bool column
            };
            dt.Rows.Add(row);
    

    and bind dt to your gridView

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

Sidebar

Related Questions

Hey guys I have an assigned array from mysql results and I simply want
Hey guys I have setup Nivo slider to my specification, but what I want
Hey guys I have enabled APC on my VPS but now I can't access
Hey guys, I have a Cocoa application that sends an NSDictionary over the network
hey guys i have got this far with a chat system but now i
Hey guys I have my script here that is supposed to do some stuff
Hey guys I have an admin page that checks if you are admin before
Hey guys I have one more question lol. I am using a script that
Hey guys I have a query that currently finds the latest comment for each
Hey guys I have what should be a simple question, but I am new

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.