Click here to Skip to main content
15,887,898 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
i need to add a time stamp to a data grid when click event. I cant find anything on the web.

What I have tried:

lots of looking and google and internet reading
Posted
Updated 30-Jul-17 9:23am
v2
Comments
BillWoodruff 29-Jul-17 19:35pm    
You need to do some work, and it's clear you haven't done any.
Member 12349103 29-Jul-17 21:02pm    
If that's the best you can do keep your comments to yourself.
Wasted 10 seconds of your lift typing that.

1. Be courteous. Everyone here helps because they enjoy helping, not because it's their job.
Graeme_Grant 30-Jul-17 19:49pm    
Berating other members won't get you help!
Karthik_Mahalingam 1-Aug-17 4:30am    
use improve question to add more info to the question.

1 solution

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GridTimeStamp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 1; i < 5; i++)
            {
                dataGridView1.Rows.Add(i.ToString(), "Data" + i.ToString(),DateTime.Now.ToFileTimeUtc());
            }
        }

        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex != 2)
                dataGridView1.Rows[e.RowIndex].Cells[2].Value = DateTime.Now.ToFileTimeUtc();
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900