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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:18:15+00:00 2026-06-04T02:18:15+00:00

I have datagridview which fills data from database, there are columns where I have

  • 0

I have datagridview which fills data from database, there are columns where I have date and time in them “MMddyyyy” and “hhmmss” format, what I want to do is when the datagridview loads, I want to change this format to some other format say, dd-MM-yy for date and for time hh-mm-ss. I was wondering if some one can guide me how to do it.
I have not been able to do this by gridview.columns[x].defaultcellstyle.format=”dd-MM-yy”
with the above I get no error but nothing is changed on the gridview …

Thanks

Note:I dont have the option to change the column length in the database as well..:-(
there are no syntax problems

  • 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-04T02:18:16+00:00Added an answer on June 4, 2026 at 2:18 am

    Microsoft suggest you intercept the CellFormatting event (where DATED is the column you want to reformat):

    private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
    {
        // If the column is the DATED column, check the
        // value.
        if (this.dataGridView1.Columns[e.ColumnIndex].Name == "DATED")
        {
            ShortFormDateFormat(e);
        }
    }
    
    private static void ShortFormDateFormat(DataGridViewCellFormattingEventArgs formatting)
    {
        if (formatting.Value != null)
        {
            try
            {
                DateTime theDate = DateTime.Parse(formatting.Value.ToString());
                String dateString = theDate.ToString("dd-MM-yy");    
                formatting.Value = dateString;
                formatting.FormattingApplied = true;
            }
            catch (FormatException)
            {
                // Set to false in case there are other handlers interested trying to
                // format this DataGridViewCellFormattingEventArgs instance.
                formatting.FormattingApplied = false;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGridView which is filling from Table in SQL Server Database. One
I have a DataGridView, which loads data from mdb Access table The grid only
Basically I have a datagridview which I retrieve from database and 3 of the
I'm trying to display set of data which have retrieved from the sql database
I have a datagridview where the users can select which subset of columns to
I have a datagridview and a combobox which get populated randomly with data. However,
I have a DataGridView which I am populating from a list of objects. However
Currently I have a DataGridView in my app which I fill from my Linq-to-SQL
I have a DataGridView in a WinForm. I fill the DataGridView from a database
I have a DataGridView which is data-bound to a BindingList. My DataGridView also has

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.