i would like to get date and time of button event. Here is the code that is writing the input from textBox11 into text file when the button 5 is clicked.

Can anyone help me advice how to write the data and time into this text file when the button is click?

....
......
this->dateTimePicker1->Location= System::Drawing::Point(49,112);
this->dateTimePicker1->Margin=System::Windows::Forms::Padding(2);
this->dateTimePicker1->Name=L"dateTimePicker1";
this->dateTimePicker1->Size=System::Drawing::Size(179,20);
this->dateTimePicker1->TabIndex=10;
this->dateTimePicker1->ValueChanges +=gcnew System::EventHand;er(this,&Form1::dateTimePicker1_ValueChange);
..
...
...
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e)
{
StreamWriter^ writeToFile=File::AppendText(openFileDialog1->FileName);
writeToFile->WriteLine("{0}",textBox11->Text);
???????????dateTimePicker ?????????
writeToFile->Close();
}
Fbody commented: You've been around long enough to know how to use [code] tags. +0

Recommended Answers

All 4 Replies

Also scroll down the page and check the box "Disable Smilies" so that all those smilies do not appear.

All you probably need is DateTime::Now.ToString() to get the current time and date. I'm not sure why you would need the picker but if you want the user to specify the date you could get it by dateTimePicker1->Value.ToString() EDIT: Was typing during FBody's post but what he says is true. Learn to use the tags or else no more help on your posts.

Since you are writing managed code you will have to find out how to get the current system date/time. There are win32 api functions such as GetSystemTime(), but that is unmanaged code.

[edit]^^ posted before I saw this. Use Jonsca's suggestion.[/edit]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.