Avatar of Peter Kiers
Peter Kiers
Flag for Netherlands asked on

How to get the creation date of a row of a listview?

Hi,

I have this code that i have put in the code-section.
When a user presses the button the code will be executed
and adds a row to the listview.
In the line that I have marked with an arrow instead of the
string "SubItem1A" I want the date and time of the creation
of the row in the listview.

Who can help me?

Peter
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
          {
            if (frmNote.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
            {
                 ListViewItem myItem = new ListViewItem(frmNote.textBox1.Text, 0);
                myItem = listView1.Items.Add(myItem);
                myItem.SubItems.Add("SubItem1a");  <====================
                myItem.SubItems.Add("SubItem1b"); 
               listView1.AutoResizeColumn(0, ColumnHeaderAutoResizeStyle.HeaderSize);
            }
        }

Open in new window

.NET ProgrammingC#

Avatar of undefined
Last Comment
MaximumIQ

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
MaximumIQ

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Peter Kiers

ASKER
I guess, but now isn't recognized.
I get :The name 'now' does not exist in the current context

P.
Peter Kiers

ASKER
Found it:
          myItem.SubItems.Add(DateTime.Now.ToString());
Peter Kiers

ASKER
500 points are comming to you...

Peter Kiers
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
MaximumIQ

Sorry, I don't know why I assumed you weren't on .NET.

Also, if you don't like the standard DateTime format you can use
DateTime.Now.Year, DateTime.Now.Month, etc.. and piece them together as strings however you like.