Hi,

There is no keypress event for datagridviewcell items... That is a
nightmare. I would like to save data to database on the grid when users
press to enter after changing value of a cell on the grid. But only
cellleave event is running on current cell. I tried to create a custom
cell and column and there is no success :( ... Any idea?

Thanks

Re: Datagridviewcell keypres... by sonsuzoyku

sonsuzoyku
Wed Oct 25 13:05:26 CDT 2006

Meanwhile, framework 2.0...


Re: Datagridviewcell keypres... by Kevin

Kevin
Wed Oct 25 13:35:21 CDT 2006

Handle the CellendEdit event. This event is called after the CellValidating
event, which is called after the CellLeave event:

1) CellLeave (old cell)
2) Cell Validating/ed (old cell)
3) CellEndEdit (old cell)

--
HTH,

Kevin Spencer
Microsoft MVP
Short Order Coder
http://unclechutney.blogspot.com

The devil is in the yada yada yada

"sonsuzoyku" <sonsuzoyku@yahoo.com> wrote in message
news:1161798220.903959.88950@e3g2000cwe.googlegroups.com...
> Hi,
>
> There is no keypress event for datagridviewcell items... That is a
> nightmare. I would like to save data to database on the grid when users
> press to enter after changing value of a cell on the grid. But only
> cellleave event is running on current cell. I tried to create a custom
> cell and column and there is no success :( ... Any idea?
>
> Thanks
>



Re: Datagridviewcell keypres... by sonsuzoyku

sonsuzoyku
Wed Oct 25 13:54:07 CDT 2006

Kevin, thanks for the replay,

But i am paranoid :). I would like to update the entire row in one db
call therefore i have to handle "enter key" press. Can i determine
which key is pressed in cellendedit method?

Best regards...



Kevin Spencer yazdi:
> Handle the CellendEdit event. This event is called after the CellValidating
> event, which is called after the CellLeave event:
>
> 1) CellLeave (old cell)
> 2) Cell Validating/ed (old cell)
> 3) CellEndEdit (old cell)
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Short Order Coder
> http://unclechutney.blogspot.com
>
> The devil is in the yada yada yada
>
> "sonsuzoyku" <sonsuzoyku@yahoo.com> wrote in message
> news:1161798220.903959.88950@e3g2000cwe.googlegroups.com...
> > Hi,
> >
> > There is no keypress event for datagridviewcell items... That is a
> > nightmare. I would like to save data to database on the grid when users
> > press to enter after changing value of a cell on the grid. But only
> > cellleave event is running on current cell. I tried to create a custom
> > cell and column and there is no success :( ... Any idea?
> >
> > Thanks
> >


Re: Datagridviewcell keypres... by Kevin

Kevin
Wed Oct 25 16:13:42 CDT 2006

I'm afraid not. You *could* write a custom DataGridViewColumn, and related
Controls, but that is an awful lot of work. I've done it before!

--
HTH,

Kevin Spencer
Microsoft MVP
Short Order Coder
http://unclechutney.blogspot.com

The devil is in the yada yada yada


"sonsuzoyku" <sonsuzoyku@yahoo.com> wrote in message
news:1161802447.427345.143850@k70g2000cwa.googlegroups.com...
> Kevin, thanks for the replay,
>
> But i am paranoid :). I would like to update the entire row in one db
> call therefore i have to handle "enter key" press. Can i determine
> which key is pressed in cellendedit method?
>
> Best regards...
>
>
>
> Kevin Spencer yazdi:
>> Handle the CellendEdit event. This event is called after the
>> CellValidating
>> event, which is called after the CellLeave event:
>>
>> 1) CellLeave (old cell)
>> 2) Cell Validating/ed (old cell)
>> 3) CellEndEdit (old cell)
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Short Order Coder
>> http://unclechutney.blogspot.com
>>
>> The devil is in the yada yada yada
>>
>> "sonsuzoyku" <sonsuzoyku@yahoo.com> wrote in message
>> news:1161798220.903959.88950@e3g2000cwe.googlegroups.com...
>> > Hi,
>> >
>> > There is no keypress event for datagridviewcell items... That is a
>> > nightmare. I would like to save data to database on the grid when users
>> > press to enter after changing value of a cell on the grid. But only
>> > cellleave event is running on current cell. I tried to create a custom
>> > cell and column and there is no success :( ... Any idea?
>> >
>> > Thanks
>> >
>



Re: Datagridviewcell keypres... by sonsuzoyku

sonsuzoyku
Thu Oct 26 02:10:56 CDT 2006

Hi Kevin and thank you,

What the trouble I dived into :). I wrote a custom datagridview edit
control, column and cell and I overrided KeyDown event of the edit
control. It works fine for all keys except return key :)))). When I
press to enter, the KeyDown event does not being fired. Is the enter
key a witch? How can it escape from the KeyDown event? Is that a
nightmare :) I really curious about its cause...

Thanks and Regards...


Re: Datagridviewcell keypres... by Kevin

Kevin
Thu Oct 26 06:20:54 CDT 2006

It is possible that the KeyDown event is being intercepted at a higher
level, such as at the DataGridView level itself, which does have a KeyDown
event handler. I'm not sure. You could work your way up, and check out where
the KeyDown event is handled first, then determine which cell (if any)
currently has the focus.

--
HTH,

Kevin Spencer
Microsoft MVP
Short Order Coder
http://unclechutney.blogspot.com

The devil is in the yada yada yada


"sonsuzoyku" <sonsuzoyku@yahoo.com> wrote in message
news:1161846656.768896.277290@m73g2000cwd.googlegroups.com...
> Hi Kevin and thank you,
>
> What the trouble I dived into :). I wrote a custom datagridview edit
> control, column and cell and I overrided KeyDown event of the edit
> control. It works fine for all keys except return key :)))). When I
> press to enter, the KeyDown event does not being fired. Is the enter
> key a witch? How can it escape from the KeyDown event? Is that a
> nightmare :) I really curious about its cause...
>
> Thanks and Regards...
>



Re: Datagridviewcell keypres... by Brendon

Brendon
Fri Oct 27 23:40:30 CDT 2006

Heya sonsuzoyku,

Have you tried the RowValidating event yet? I use it to trap if a row
isCurrentRowDirty and then save as I do... You do need to set up a boolean
value for when you are opening your form or the event gets called each time
a new row is painted and populated into the grid

[code]
Private Sub dgvCurrentYear_RowValidating(ByVal sender As Object,
ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles
dgvCurrentYear.RowValidating
If Not m_initialising Then
If DirectCast(sender, DataGridView).IsCurrentRowDirty Then
dirtyRowSave(DirectCast(sender,
DataGridView).CurrentRow.Index)
End If
End If
End Sub
[/code]

HTH
Brendon

"sonsuzoyku" <sonsuzoyku@yahoo.com> wrote in message
news:1161846656.768896.277290@m73g2000cwd.googlegroups.com...
> Hi Kevin and thank you,
>
> What the trouble I dived into :). I wrote a custom datagridview edit
> control, column and cell and I overrided KeyDown event of the edit
> control. It works fine for all keys except return key :)))). When I
> press to enter, the KeyDown event does not being fired. Is the enter
> key a witch? How can it escape from the KeyDown event? Is that a
> nightmare :) I really curious about its cause...
>
> Thanks and Regards...
>


Re: Datagridviewcell keypres... by sonsuzoyku

sonsuzoyku
Mon Oct 30 02:54:36 CST 2006

Thanks for the response Brendon that solves my problem... But the
KeyDown event is still in suspense :). When i will got enough time, i
will perform some work arount about it. Thanks again...



Brendon Bezuidenhout wrote:
> Heya sonsuzoyku,
>
> Have you tried the RowValidating event yet? I use it to trap if a row
> isCurrentRowDirty and then save as I do... You do need to set up a boolean
> value for when you are opening your form or the event gets called each time
> a new row is painted and populated into the grid
>
> [code]
> Private Sub dgvCurrentYear_RowValidating(ByVal sender As Object,
> ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles
> dgvCurrentYear.RowValidating
> If Not m_initialising Then
> If DirectCast(sender, DataGridView).IsCurrentRowDirty Then
> dirtyRowSave(DirectCast(sender,
> DataGridView).CurrentRow.Index)
> End If
> End If
> End Sub
> [/code]
>
> HTH
> Brendon
>
> "sonsuzoyku" <sonsuzoyku@yahoo.com> wrote in message
> news:1161846656.768896.277290@m73g2000cwd.googlegroups.com...
> > Hi Kevin and thank you,
> >
> > What the trouble I dived into :). I wrote a custom datagridview edit
> > control, column and cell and I overrided KeyDown event of the edit
> > control. It works fine for all keys except return key :)))). When I
> > press to enter, the KeyDown event does not being fired. Is the enter
> > key a witch? How can it escape from the KeyDown event? Is that a
> > nightmare :) I really curious about its cause...
> >
> > Thanks and Regards...
> >