From: Mr. X. on
I want to clear not the whole binding, but partial.

The situation is :
I have a main screen, which has a dataGridView, which connected to
datasource by BindingSource object.
Also a sub screen called by the main screen, which has textBox object on it,
which also connected to the same bindSource object.

For simplicaty :
main screen = frmMain
data grid view - dgMain
BindingSource - bsMain (a local variable in each form - main and subform,
that has the same value for both).
sub screen = frmSubScreen
text box (on the sub-screen) - txtSubTestValue

On dgMain there are two rows (also two rows in the table of database).
First time I am on the first row of dgMain.
When clicking to show the frmSubScreen - subScreen has the current row
selected.
Now I am changing the txtSubTestValue, which is connected to a field.
.... Now I want to do cancel : I did bsMain.cancelEdit, but I know this
wrong - why ???
I am closing frmSubScreen, and return to frmMain.
If I check now the bsMain.current.Row.RowState = unchanged.
Now I am choosing the second row of dgMain,
and go again to the first row of dgMain (which I have changed, but did
:bsMain.cancelEdit).
But ...
Now unexpectedly bsMain.current.Row.RowState = modified - Why ???

And what is the best approach solving this problem ?

(For other situation, whether the original state is modified - It was
solved, by a function I have made. I only need to set the original value of
each column, which I keep it on an array, which holds all the related object
on screen, that has databinding on it).

Thanks :)

From: Mr. X. on
Look at my question-response to Michel...

Thanks :)
From: Cor Ligthert[MVP] on
Do you really think that we are magicians, you are behind your screen with
the full code before you, using a database which we not have.

This means the same like we do in this kind of situations, much tears and
sometimes sweat.

Luckily no blood.


"Mr. X." <nospam(a)nospam_please.com> wrote in message
news:eCFMW9b1KHA.6104(a)TK2MSFTNGP06.phx.gbl...
> I want to clear not the whole binding, but partial.
>
> The situation is :
> I have a main screen, which has a dataGridView, which connected to
> datasource by BindingSource object.
> Also a sub screen called by the main screen, which has textBox object on
> it, which also connected to the same bindSource object.
>
> For simplicaty :
> main screen = frmMain
> data grid view - dgMain
> BindingSource - bsMain (a local variable in each form - main and subform,
> that has the same value for both).
> sub screen = frmSubScreen
> text box (on the sub-screen) - txtSubTestValue
>
> On dgMain there are two rows (also two rows in the table of database).
> First time I am on the first row of dgMain.
> When clicking to show the frmSubScreen - subScreen has the current row
> selected.
> Now I am changing the txtSubTestValue, which is connected to a field.
> ... Now I want to do cancel : I did bsMain.cancelEdit, but I know this
> wrong - why ???
> I am closing frmSubScreen, and return to frmMain.
> If I check now the bsMain.current.Row.RowState = unchanged.
> Now I am choosing the second row of dgMain,
> and go again to the first row of dgMain (which I have changed, but did
> :bsMain.cancelEdit).
> But ...
> Now unexpectedly bsMain.current.Row.RowState = modified - Why ???
>
> And what is the best approach solving this problem ?
>
> (For other situation, whether the original state is modified - It was
> solved, by a function I have made. I only need to set the original value
> of each column, which I keep it on an array, which holds all the related
> object on screen, that has databinding on it).
>
> Thanks :)

From: Michel Posseth [MCP] on
Hello Mr.X.


After thorough reading of your provided details my answer still stands call
reject changes on the datasource the datsource is the dataset , datatable or
datarow
in your described situation the datarow reject changes should be called

the why ? part

http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/868d17f9-fad2-4e96-aab0-02c953ef87d0


:-)


regards

Michel Posseth



"Mr. X." <nospam(a)nospam_please.com> schreef in bericht
news:eCFMW9b1KHA.6104(a)TK2MSFTNGP06.phx.gbl...
>I want to clear not the whole binding, but partial.
>
> The situation is :
> I have a main screen, which has a dataGridView, which connected to
> datasource by BindingSource object.
> Also a sub screen called by the main screen, which has textBox object on
> it, which also connected to the same bindSource object.
>
> For simplicaty :
> main screen = frmMain
> data grid view - dgMain
> BindingSource - bsMain (a local variable in each form - main and subform,
> that has the same value for both).
> sub screen = frmSubScreen
> text box (on the sub-screen) - txtSubTestValue
>
> On dgMain there are two rows (also two rows in the table of database).
> First time I am on the first row of dgMain.
> When clicking to show the frmSubScreen - subScreen has the current row
> selected.
> Now I am changing the txtSubTestValue, which is connected to a field.
> ... Now I want to do cancel : I did bsMain.cancelEdit, but I know this
> wrong - why ???
> I am closing frmSubScreen, and return to frmMain.
> If I check now the bsMain.current.Row.RowState = unchanged.
> Now I am choosing the second row of dgMain,
> and go again to the first row of dgMain (which I have changed, but did
> :bsMain.cancelEdit).
> But ...
> Now unexpectedly bsMain.current.Row.RowState = modified - Why ???
>
> And what is the best approach solving this problem ?
>
> (For other situation, whether the original state is modified - It was
> solved, by a function I have made. I only need to set the original value
> of each column, which I keep it on an array, which holds all the related
> object on screen, that has databinding on it).
>
> Thanks :)

From: Mr. X. on
O.K.
Good link - Thank you very much.

Problem solved.
I think I understand now.
I don�t need any special routine.
For the main screen and sub screen - I created a new BindSource (not the
same one, not point to the same memory,
but both are linked to the same datasource).
For the sub screen I did cancelEdit.
Because it acts as layers - at the most top screen I should do a
AcceptChanges or RejectChanges for the whole row
(That will change only in memory ... or dataadapter.update if I realy want
to update in database).

I see - when I first changing any of the linked object to datasource - the
is "auto-BeginEdit", so I don't need to worry about it.

Thanks :)