Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Simple Datagrid question

Reply
 
Old 01-23-2009   #1 (permalink)
Miro


 
 

Simple Datagrid question

Simple perhaps to you - but not to me. :-)

Here is a quick question I just cant seem to find a solution for. (im using
vb.net but i dont think that matters in this case).

I created a dummy datagrid - linked to a dataset.
on it are 3 columns:

date, combobox, checkbox

now...go to a current record and click the comobo box and drop down to a new
item in the list.
selecting that list, the record goes into 'edit mode ( left pencil in the
datagrid view ).

Now if I hit my 'save' button right now, it doesnt actaully save that
change.
It will save it if I hit 'enter' or 'tab' first. ( Pencil turns back to
black arrow )

Is this normal of a .net datagrid ?
Is there anyway around it - some code i can put somewhere so i dont click a
dropdown, and hit save right away, but really I havnt changed the field
column yet until I hit the enter key or tab key or click to another field /
column / record.

Hope that makes sense.

Thanks

Miro


My System SpecsSystem Spec
Old 01-23-2009   #2 (permalink)
Miro


 
 

Re: Simple Datagrid question

Found it - i think

I must put this code wherever I want it to take the current input ( still in
edit mode ) of a cell.

DataGrid.endedit()

Miro

"Miro" <miro@xxxxxx> wrote in message
news:OUcXxQafJHA.4728@xxxxxx
Quote:

> Simple perhaps to you - but not to me. :-)
>
> Here is a quick question I just cant seem to find a solution for. (im
> using vb.net but i dont think that matters in this case).
>
> I created a dummy datagrid - linked to a dataset.
> on it are 3 columns:
>
> date, combobox, checkbox
>
> now...go to a current record and click the comobo box and drop down to a
> new item in the list.
> selecting that list, the record goes into 'edit mode ( left pencil in the
> datagrid view ).
>
> Now if I hit my 'save' button right now, it doesnt actaully save that
> change.
> It will save it if I hit 'enter' or 'tab' first. ( Pencil turns back to
> black arrow )
>
> Is this normal of a .net datagrid ?
> Is there anyway around it - some code i can put somewhere so i dont click
> a dropdown, and hit save right away, but really I havnt changed the field
> column yet until I hit the enter key or tab key or click to another field
> / column / record.
>
> Hope that makes sense.
>
> Thanks
>
> Miro
My System SpecsSystem Spec
Old 01-23-2009   #3 (permalink)
Miro


 
 

Re: Simple Datagrid question

And as well to finish off this post I had to add this:

BindingContext(MyBindingSource).EndCurrentEdit()
to keep the last 'added' line to the binding source as well.

Im still trying to read up on 'BindingContext' on what it actually does but
those two lines of code did the trick for me.

Cheers' - sorry for all the posts.

Miro

"Miro" <miro@xxxxxx> wrote in message
news:umw2qWafJHA.1292@xxxxxx
Quote:

> Found it - i think
>
> I must put this code wherever I want it to take the current input ( still
> in edit mode ) of a cell.
>
> DataGrid.endedit()
>
> Miro
>
> "Miro" <miro@xxxxxx> wrote in message
> news:OUcXxQafJHA.4728@xxxxxx
Quote:

>> Simple perhaps to you - but not to me. :-)
>>
>> Here is a quick question I just cant seem to find a solution for. (im
>> using vb.net but i dont think that matters in this case).
>>
>> I created a dummy datagrid - linked to a dataset.
>> on it are 3 columns:
>>
>> date, combobox, checkbox
>>
>> now...go to a current record and click the comobo box and drop down to a
>> new item in the list.
>> selecting that list, the record goes into 'edit mode ( left pencil in the
>> datagrid view ).
>>
>> Now if I hit my 'save' button right now, it doesnt actaully save that
>> change.
>> It will save it if I hit 'enter' or 'tab' first. ( Pencil turns back to
>> black arrow )
>>
>> Is this normal of a .net datagrid ?
>> Is there anyway around it - some code i can put somewhere so i dont click
>> a dropdown, and hit save right away, but really I havnt changed the field
>> column yet until I hit the enter key or tab key or click to another field
>> / column / record.
>>
>> Hope that makes sense.
>>
>> Thanks
>>
>> Miro
>
My System SpecsSystem Spec
Old 01-24-2009   #4 (permalink)
Cor Ligthert[MVP]


 
 

Re: Simple Datagrid question

Miro,

I thought the latter was not anymore necessary in versions behind 2003,
endedit should be enough.

Cor

"Miro" <miro@xxxxxx> wrote in message
news:eR%23kdfafJHA.5844@xxxxxx
Quote:

> And as well to finish off this post I had to add this:
>
> BindingContext(MyBindingSource).EndCurrentEdit()
> to keep the last 'added' line to the binding source as well.
>
> Im still trying to read up on 'BindingContext' on what it actually does
> but those two lines of code did the trick for me.
>
> Cheers' - sorry for all the posts.
>
> Miro
>
> "Miro" <miro@xxxxxx> wrote in message
> news:umw2qWafJHA.1292@xxxxxx
Quote:

>> Found it - i think
>>
>> I must put this code wherever I want it to take the current input ( still
>> in edit mode ) of a cell.
>>
>> DataGrid.endedit()
>>
>> Miro
>>
>> "Miro" <miro@xxxxxx> wrote in message
>> news:OUcXxQafJHA.4728@xxxxxx
Quote:

>>> Simple perhaps to you - but not to me. :-)
>>>
>>> Here is a quick question I just cant seem to find a solution for. (im
>>> using vb.net but i dont think that matters in this case).
>>>
>>> I created a dummy datagrid - linked to a dataset.
>>> on it are 3 columns:
>>>
>>> date, combobox, checkbox
>>>
>>> now...go to a current record and click the comobo box and drop down to a
>>> new item in the list.
>>> selecting that list, the record goes into 'edit mode ( left pencil in
>>> the datagrid view ).
>>>
>>> Now if I hit my 'save' button right now, it doesnt actaully save that
>>> change.
>>> It will save it if I hit 'enter' or 'tab' first. ( Pencil turns back to
>>> black arrow )
>>>
>>> Is this normal of a .net datagrid ?
>>> Is there anyway around it - some code i can put somewhere so i dont
>>> click a dropdown, and hit save right away, but really I havnt changed
>>> the field column yet until I hit the enter key or tab key or click to
>>> another field / column / record.
>>>
>>> Hope that makes sense.
>>>
>>> Thanks
>>>
>>> Miro
>>
>
My System SpecsSystem Spec
Old 01-24-2009   #5 (permalink)
Miro


 
 

Re: Simple Datagrid question

You are correct (it worked with the first line)- but I had to add that so
when the datagridview automatically adds the next row - it stays as well.

Hard to know what to google for when you dont know what to google for

I found the first line
DataGrid.endedit()
allowed the changed cell to stay...

and this line:
BindingContext(MyBindingSource).EndCurrentEdit()
Kept the automatic line added by automatic addrows in the datagrid when a
save was done.

Cheers'

Miro

"Cor Ligthert[MVP]" <Notmyfirstname@xxxxxx> wrote in message
news:OmcNiEgfJHA.1252@xxxxxx
Quote:

> Miro,
>
> I thought the latter was not anymore necessary in versions behind 2003,
> endedit should be enough.
>
> Cor
>
> "Miro" <miro@xxxxxx> wrote in message
> news:eR%23kdfafJHA.5844@xxxxxx
Quote:

>> And as well to finish off this post I had to add this:
>>
>> BindingContext(MyBindingSource).EndCurrentEdit()
>> to keep the last 'added' line to the binding source as well.
>>
>> Im still trying to read up on 'BindingContext' on what it actually does
>> but those two lines of code did the trick for me.
>>
>> Cheers' - sorry for all the posts.
>>
>> Miro
>>
>> "Miro" <miro@xxxxxx> wrote in message
>> news:umw2qWafJHA.1292@xxxxxx
Quote:

>>> Found it - i think
>>>
>>> I must put this code wherever I want it to take the current input (
>>> still in edit mode ) of a cell.
>>>
>>> DataGrid.endedit()
>>>
>>> Miro
>>>
>>> "Miro" <miro@xxxxxx> wrote in message
>>> news:OUcXxQafJHA.4728@xxxxxx
>>>> Simple perhaps to you - but not to me. :-)
>>>>
>>>> Here is a quick question I just cant seem to find a solution for. (im
>>>> using vb.net but i dont think that matters in this case).
>>>>
>>>> I created a dummy datagrid - linked to a dataset.
>>>> on it are 3 columns:
>>>>
>>>> date, combobox, checkbox
>>>>
>>>> now...go to a current record and click the comobo box and drop down to
>>>> a new item in the list.
>>>> selecting that list, the record goes into 'edit mode ( left pencil in
>>>> the datagrid view ).
>>>>
>>>> Now if I hit my 'save' button right now, it doesnt actaully save that
>>>> change.
>>>> It will save it if I hit 'enter' or 'tab' first. ( Pencil turns back
>>>> to black arrow )
>>>>
>>>> Is this normal of a .net datagrid ?
>>>> Is there anyway around it - some code i can put somewhere so i dont
>>>> click a dropdown, and hit save right away, but really I havnt changed
>>>> the field column yet until I hit the enter key or tab key or click to
>>>> another field / column / record.
>>>>
>>>> Hope that makes sense.
>>>>
>>>> Thanks
>>>>
>>>> Miro
>>>
>>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
DataGrid Question .NET General
DataGrid Question .NET General
Simple question .NET General
simple question... really! Vista General
a simple question Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46