Link to home
Start Free TrialLog in
Avatar of Peter Kiers
Peter KiersFlag 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

ASKER CERTIFIED SOLUTION
Avatar of MaximumIQ
MaximumIQ
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Peter Kiers

ASKER

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

P.
Found it:
          myItem.SubItems.Add(DateTime.Now.ToString());
500 points are comming to you...

Peter Kiers
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.