Home All Groups Group Topic Archive Search About

DataGrid only sets HasChanges to true if another row is selected

Author
4 Jan 2007 8:06 PM
John Sitka
Hi,

I have a datagrid that has as it's datasource a filtered datview of the underlying datatable.
The datagrid is set to read only.
When the row header column is clicked it fills a series of textboxes, datapickers etc positioned
below the datagrid on the same form for ease of editing.
Once edits are complete the save button moves these values back to their respective positions in the
seleceted row of the datagrid, then updates the dataadapter across the underlying datatable.
The changes written to the visible datagrid do not mark themselves as changes unless a mouse click
happens somewhere in the datagrid.

How can I program the datagrid to recognize the changes and communicate them to the underlying
datatable without the click?
I was hoping by setting
dataGrid1.CurrentRowIndex = -1
Which represents a Row change from any possible Selected row would do it, but it dosen't.

Thanks

Author
4 Jan 2007 11:25 PM
Bart Mermuys
Hi,

Show quote
"John Sitka" <johnsi***@REMOVEhotmail.com> wrote in message
news:etJtGvDMHHA.780@TK2MSFTNGP03.phx.gbl...
> Hi,
>
> I have a datagrid that has as it's datasource a filtered datview of the
> underlying datatable.
> The datagrid is set to read only.
> When the row header column is clicked it fills a series of textboxes,
> datapickers etc positioned
> below the datagrid on the same form for ease of editing.
> Once edits are complete the save button moves these values back to their
> respective positions in the
> seleceted row of the datagrid, then updates the dataadapter across the
> underlying datatable.
> The changes written to the visible datagrid do not mark themselves as
> changes unless a mouse click
> happens somewhere in the datagrid.

Try calling EndCurrentEdit on the CurrencyManager (manages the list binding)
returned from BindingContext to make sure editing has ended before updating
or calling getchanges:

BindingContext[dataGrid1.DataSource,dataGrid1.DataMember].EndCurrentEdit();
dataAdapter.Update( ... );


HTH,
Greetings


Show quote
>
> How can I program the datagrid to recognize the changes and communicate
> them to the underlying
> datatable without the click?
> I was hoping by setting
> dataGrid1.CurrentRowIndex = -1
> Which represents a Row change from any possible Selected row would do it,
> but it dosen't.
>
> Thanks
>
>
>
>
Author
5 Jan 2007 1:06 PM
John Sitka
Thanks,
I have use the CurrencyManager successfully in the past and I think I need to re look at how I wrote that code.
That was in much more complicated control (list view and datgrids combined) code with drag and drop add
delete (to trash can), list ranking reordering and stuff but in this case it is much more simple.

Just a filtered grid, to see what you need to see at the moment.
Click on a row header to copy the row values to the editing controls (text, datepickers,comboboxes)
then push those edits back to the grid.
Much like a basic Access form would behave, but with the explict need to click a button to acknowledge
that these are the edits that are intended, rather than direct row editing.

My attempts at utilizing the currency manager seem to be missing the mark, I'll find it soon but believe it or not
for now, this works.

dataGrid1.SelectNextControl(this.uxlblcustno,true,false,false,false);

It is somehow sending an event to select one of the readonly cells in the row I'm working on,
which then lets the bindings to the datagrid know that something has changed.
I can't explain it, especially since uxlblcustno is just any old label on the main form?

Graphically it changes how the dataGrid row selection looks, the row is still highlighted but the
first column is kiind of in some superimpossed editng state.

Anyways, I was hung up on this and it got me over the GUI test stage for a meeting with target audience.
That will help redefine the scope of this project and by then who knows.

Thanks lots.





Show quote
"Bart Mermuys" <bmermuys.nospam@hotmail.com> wrote in message news:m1gnh.273447$DW5.5578854@phobos.telenet-ops.be...
> Hi,
>
> "John Sitka" <johnsi***@REMOVEhotmail.com> wrote in message news:etJtGvDMHHA.780@TK2MSFTNGP03.phx.gbl...
>> Hi,
>>
>> I have a datagrid that has as it's datasource a filtered datview of the underlying datatable.
>> The datagrid is set to read only.
>> When the row header column is clicked it fills a series of textboxes, datapickers etc positioned
>> below the datagrid on the same form for ease of editing.
>> Once edits are complete the save button moves these values back to their respective positions in the
>> seleceted row of the datagrid, then updates the dataadapter across the underlying datatable.
>> The changes written to the visible datagrid do not mark themselves as changes unless a mouse click
>> happens somewhere in the datagrid.
>
> Try calling EndCurrentEdit on the CurrencyManager (manages the list binding) returned from BindingContext to make sure editing has
> ended before updating or calling getchanges:
>
> BindingContext[dataGrid1.DataSource,dataGrid1.DataMember].EndCurrentEdit();
> dataAdapter.Update( ... );
>
>
> HTH,
> Greetings
>
>
>>
>> How can I program the datagrid to recognize the changes and communicate them to the underlying
>> datatable without the click?
>> I was hoping by setting
>> dataGrid1.CurrentRowIndex = -1
>> Which represents a Row change from any possible Selected row would do it, but it dosen't.
>>
>> Thanks
>>
>>
>>
>>
>
>
Author
6 Jan 2007 4:52 PM
Bart Mermuys
Hi,

Show quote
"John Sitka" <johnsi***@REMOVEhotmail.com> wrote in message
news:udWNBwMMHHA.4376@TK2MSFTNGP04.phx.gbl...
> Thanks,
> I have use the CurrencyManager successfully in the past and I think I need
> to re look at how I wrote that code.
> That was in much more complicated control (list view and datgrids
> combined) code with drag and drop add
> delete (to trash can), list ranking reordering and stuff but in this case
> it is much more simple.
>
> Just a filtered grid, to see what you need to see at the moment.
> Click on a row header to copy the row values to the editing controls
> (text, datepickers,comboboxes)
> then push those edits back to the grid.
> Much like a basic Access form would behave, but with the explict need to
> click a button to acknowledge
> that these are the edits that are intended, rather than direct row
> editing.

Yes i understand that, but even for such a simple case you may need to use a
CurrencyManager mostly for EndCurrentEdit().

A lot of people do have trouble getting the right CurrencyManager.  So if
you try, use my exact code.

Show quote
>
> My attempts at utilizing the currency manager seem to be missing the mark,
> I'll find it soon but believe it or not
> for now, this works.
>
> dataGrid1.SelectNextControl(this.uxlblcustno,true,false,false,false);
>
> It is somehow sending an event to select one of the readonly cells in the
> row I'm working on,
> which then lets the bindings to the datagrid know that something has
> changed.
> I can't explain it, especially since uxlblcustno is just any old label on
> the main form?
>

For me CurrencyManager.EndCurrentEdit() seems to work.

HTH,
Greetings


Show quote
> Graphically it changes how the dataGrid row selection looks, the row is
> still highlighted but the
> first column is kiind of in some superimpossed editng state.
>
> Anyways, I was hung up on this and it got me over the GUI test stage for a
> meeting with target audience.
> That will help redefine the scope of this project and by then who knows.
>
> Thanks lots.
>
>
>
>
>
> "Bart Mermuys" <bmermuys.nospam@hotmail.com> wrote in message
> news:m1gnh.273447$DW5.5578854@phobos.telenet-ops.be...
>> Hi,
>>
>> "John Sitka" <johnsi***@REMOVEhotmail.com> wrote in message
>> news:etJtGvDMHHA.780@TK2MSFTNGP03.phx.gbl...
>>> Hi,
>>>
>>> I have a datagrid that has as it's datasource a filtered datview of the
>>> underlying datatable.
>>> The datagrid is set to read only.
>>> When the row header column is clicked it fills a series of textboxes,
>>> datapickers etc positioned
>>> below the datagrid on the same form for ease of editing.
>>> Once edits are complete the save button moves these values back to their
>>> respective positions in the
>>> seleceted row of the datagrid, then updates the dataadapter across the
>>> underlying datatable.
>>> The changes written to the visible datagrid do not mark themselves as
>>> changes unless a mouse click
>>> happens somewhere in the datagrid.
>>
>> Try calling EndCurrentEdit on the CurrencyManager (manages the list
>> binding) returned from BindingContext to make sure editing has ended
>> before updating or calling getchanges:
>>
>> BindingContext[dataGrid1.DataSource,dataGrid1.DataMember].EndCurrentEdit();
>> dataAdapter.Update( ... );
>>
>>
>> HTH,
>> Greetings
>>
>>
>>>
>>> How can I program the datagrid to recognize the changes and communicate
>>> them to the underlying
>>> datatable without the click?
>>> I was hoping by setting
>>> dataGrid1.CurrentRowIndex = -1
>>> Which represents a Row change from any possible Selected row would do
>>> it, but it dosen't.
>>>
>>> Thanks
>>>
>>>
>>>
>>>
>>
>>
>
>
Author
5 Jan 2007 5:35 AM
Cor Ligthert [MVP]
John,

In addition to Bart you can make your life easier by using the position from
the currency manager as Bart has already descibed.

http://www.vb-tips.com/dbpages.aspx?ID=869eb278-0b5f-4dfd-8068-4e3f3fedb997

Put as well a DataGridView on your form with as datasource the
datasourcemanager.

You can even remove the buttons if you want,

Cor
Author
5 Jan 2007 1:18 PM
John Sitka
Thanks Cor,

Nice example.....

(but...oh no not again,)

BindingSource

I'm writing to  Net 1.1 framework



Show quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:%23D75BsIMHHA.4708@TK2MSFTNGP02.phx.gbl...
> John,
>
> In addition to Bart you can make your life easier by using the position from the currency manager as Bart has already descibed.
>
> http://www.vb-tips.com/dbpages.aspx?ID=869eb278-0b5f-4dfd-8068-4e3f3fedb997
>
> Put as well a DataGridView on your form with as datasource the datasourcemanager.
>
> You can even remove the buttons if you want,
>
> Cor
>
Author
5 Jan 2007 7:47 PM
Cor Ligthert [MVP]
john,

Just one row above it.

We are busy with our site.

http://www.vb-tips.com/dbpages.aspx?ID=c6c7d9a8-7511-41a1-a488-2e91e5295e7c

Cor

Show quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schreef in bericht
news:%23D75BsIMHHA.4708@TK2MSFTNGP02.phx.gbl...
> John,
>
> In addition to Bart you can make your life easier by using the position
> from the currency manager as Bart has already descibed.
>
> http://www.vb-tips.com/dbpages.aspx?ID=869eb278-0b5f-4dfd-8068-4e3f3fedb997
>
> Put as well a DataGridView on your form with as datasource the
> datasourcemanager.
>
> You can even remove the buttons if you want,
>
> Cor
>

AddThis Social Bookmark Button