|
Hello,
I have a bound DataGridView with one of the columns bound to a date field. If date is entered as 31-08-2009 everything works fine, but user wants to fill in the date as 31082009 (European format).
On the cell leave event I have:
if (this.dgvInvoice.Columns[e.ColumnIndex].Name == "DateColumn")
{
string DateText = this.dgvInvoice.Rows[e.RowIndex].Cells["DateColumn"].EditedFormattedValue.ToString();
try
{
this.dgvInvoice.Rows[e.RowIndex].Cells["DateColumn"].Value =
customfunction(DateText);
}
catch
{
this.dgvInvoice.Rows[e.RowIndex].Cells["DateColumn"].Value = DateTime.Today;
}
}
}
The customfunction returns a date like 31-08-2009. The try goes well, but still I have an exception that it's not a valid DateTime.
The EditedFormattedValue is not writeable, and after I set the Value, the EditedFormattedValue is still the same.
How can I solve this ?
Thanks in advance.
Rob
|
|
|
|
|
Hi Rob!
It seems you use CellLeave event of the grid and alter leaving the event logic the value not always updates correctly.This event is fired when cell lose its focus,not when it was edited by the user.You would better use CellEndEdit event.
|
|
|
|
|
Alas, the exception about a bad date is thrown before the endedit event is raised.
Any other suggestions ?
Thanks,
Rob
|
|
|
|
|
What kind of DataSource are you using for your grid?
Is it DataTable or someone else?
|
|
|
|
|
It's a datatable. The specific column is a date field in the datatable.
Rob
|
|
|
|
|
I think this have to solve your problem :
private void Grid_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
{
if (this.dgvInvoice.Columns[e.ColumnIndex].Name == "DateColumn")
{
try
{
e.Value=customfunction(e.Value);
}
catch
{
e.Value = DateTime.Today;
}
}
e.ParsingApplied = true;
}
Cheers!
|
|
|
|
|
Thanks for your efforts, I gave a thumbs up.
Unfortunately the parse event didn't give the desired results either.
I've solved the problem by making an extra unbound text column, hiding the date column, and on the validating event from the new unbound text column the hidden "real" date column is filled.
It's not pretty but it works.
Rob
|
|
|
|
|
To test the events, I tried the dataerror event, but with no luck, I can catch the exception (which is ugly), but the value doesn't write through to the EditedFormattedValue.
so still looking for a solution.
Rob
|
|
|
|
|
Consider that there are two files named file1.txt and file2.txt.
file1.txt consists 50lines
file2.txt consists 50lines
Now I want to compare the text of two files taht to line by line,
I mean How can I compare 1st line of file1.txt with 1st line of file2.txt
similarly 2nd line of file1.txt with 2nd line of file2.txt, etc., till the last line
|
|
|
|
|
string[] file1 = File.ReadAllLines("file1.txt");
string[] file2 = File.ReadAllLines("file2.txt");
then use "for" to go through the array and compare it.
|
|
|
|
|
You have to use StreamReader
Suppose you have Two streamreader objects
sr1 and sr2
while((str1=sr1.ReadLine())!="" &&(str2=sr2.ReadLine()))
{
if(str1!=str2)
//The Files Are different...
}
Vinod Kumar Prajapati
Software Engineer
EBC Publishing Pvt. Ltd.
|
|
|
|
|
Hi,
Is anyone can help me? please.
I have a small project that I need to view a certain document file in my program, example a .doc file.
Is there any class or a control that I can used to view this certain document?
You're help is appreciated.
Thanks in advance.
regards,
erson
|
|
|
|
|
RichTextBox might suit the needs.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Is there a possibility that I can embed the text editor of the winword.exe? but only to view such a text and also the graphics, there is no menu and toolbar. Is that possible?
best regards,
erson
|
|
|
|
|
Have you checked the RichTextBox? It has a lot of features which you might like. As far as embedding the winword.exe is concerned you can start the process outside the application but no idea about embedding it.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Thank you with this kind of information
It help my problem.
kind regards,
erson
|
|
|
|
|
i would like to upload the videos in any format and convert it in .flv or swf formats using VS 2008....
is there any third party control available for asp.net/C#
|
|
|
|
|
|
THANX stancrm
i have downloaded class library..
as i am new in the programming, can you plz help me out how to use it in my web page
thanks in advance
|
|
|
|
|
If you are new to programming, then buy a book, learn first C#, learn first something easy.
Video convertion is not so easy.
|
|
|
|
|
not that new to buy a book
actually i havnt use any external library yet,
|
|
|
|
|
|
Are you tryed Video to Flash Converter Pro ( geovid )? It must help...
|
|
|
|
|
Hello there I am currently coding a RPG game and need a good book to help me check some of my work (and also give me some ideas) I have already a good knowledge of how to code, so I don't really need to know the basics, can anyone recommend a good book?
Just remember I am programming in vs2005, so please only books which apply to this.
|
|
|
|
|
If I were you, I'd consider using XNA to help you out (it integrates into Visual Studio). This link[^] seems promising; I know it's not a book, but it looks like a decent resource, and there are links to books on XNA in there as well.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|