[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

Re: Editing cells in a DataGridView

Atif Shehzad

7/13/2011 3:33:00 AM

I know its and old old thread, but I am posting for good (in case some1 looks for it same as I could not figure a solution to a similar problem of firing an event twice).
I suggest use CellEndEdit event instead.
CellValueChanged is fired once when user enters a value and second time when you change the value to update it.

> On Tuesday, June 12, 2007 3:36 PM Thomas wrote:

> How do you apply formatting to edited cells in a datagridview? I want
> to allow the user to type text in either upper or lowercase but after
> their edit is complete, I need to shift the value to uppercase.
>
> Here's what I doing:
>
> Private Sub dgridviewAppSettings_CellValueChanged(ByVal sender As
> Object, ByVal e As DataGridViewCellEventArgs) Handles
> dgridviewAppSettings.CellValueChanged
>
> dgridviewAppSettings.CurrentCell().Value =
> dgridviewAppSettings.CurrentCell().Value.ToString().ToUpper
>
> End Sub
>
> This works but the event is fired twice since I'm programmatically
> editing the cell after the user does. Is there a way to prevent this?
>
> TIA,
> Thomas