Dave,
This does not change anything. My main project does not even have the code
to update the title bar, it only looks for changes when the user presses
update and/or when the form is closed. The main project get the change and
passes them to a SQL data adaptor which then does its thing.
The problem is my control and not the form or the DataSet. I need to
modify the way the control was created or the way it is bound to the data.
I am at a loss for which.
Regards,
John
"Dave Sexton" <dave@jwa[remove.this]online.com> wrote in message
news:(E-Mail Removed)...
> Hi John,
>
> I just had some time to look at the code you attached.
>
> The DataGridView.SelectionChanged method seems to be raised in the middle
> of navigating the data source, not after navigation is complete. To be
> honest I don't know why this is happening on that particular event but it
> seems that the DataGridView does in fact change the state of a DataRow
> while navigating the DataSet, however the changes are lost after
> navigation is complete. Perhaps binding to a BindingSource object instead
> will alleviate the problem.
>
> To work around the issue while binding directly to a DataSet do the
> following:
>
> 1. Remove your DataGridView.SelectionChanged event handler
> 2. Place the following line of code at the end of the Form.Load event
> handler:
>
> ((CurrencyManager) this.BindingContext[dataSet1, "Table1"]).ListChanged
> += new ListChangedEventHandler(Form1_ListChanged);
>
> 3. Create the following event handler for the ListChanged event of your
> data source:
>
> private void Form1_ListChanged(object sender, ListChangedEventArgs e)
> {
> this.DisplayChangeCount();
> }
>
> Using the ListChanged event of the CurrencyManager for the Form will
> ensure that the TitleBar is only updated when 'real' changes occur to the
> DataSet.
>
> HTH
>
> "John J. Hughes II" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Dave,
>>
>> Thank you for your patience.
>>
>> One line question (don't think it will help):
>> How do you create a custom user control to be binded to a DataSet so the
>> DataSet knows when the data used by the control is updated?
>>
>> *****************************************************
>> Reboot... attached find a small project to demo my problem. (VS2005)
>>
>> When run the main form show a DataGridView which shows the first column
>> of several records. To the right is two controls, one is a rich text
>> box and the other is my custom control. At this point the custom
>> control does not do anything expect display the size, later it will need
>> to modify the data (another topic).
>>
>> In the title bar is the number of records that have been changed, at this
>> point we don't care about saving the data.
>>
>> Now in my opinion as I move up and down though the rows the title bar
>> value should always show -0- unless something is edited.
>>
>> If you comment out the follow line the title bar will always show -0- but
>> if the line is not commented out then each time the row is changed the
>> title bar increments by one.
>>
>> /// Title bar changes count
>> public Form1()
>> {
>> InitializeComponent();
>> this.userControl11.DataBindings.Add(new
>> System.Windows.Forms.Binding("MsgData", this.dataSet1, "Table1.Data",
>> false));
>> }
>>
>> /// Title bar does not change count
>> public Form1()
>> {
>> InitializeComponent();
>> /// this.userControl11.DataBindings.Add(new
>> System.Windows.Forms.Binding("MsgData", this.dataSet1, "Table1.Data",
>> false));
>> }
>>
>> **************************************************
>>
>> Note in the project is a second custom user control which uses a string
>> instead of a byte array. If this is used in place of the rich text
>> control then the records change each time the row changes. I have
>> concluded from this that the binding does not compare the value but is
>> using some other method to determine the value has changed.
>>
>> Regards,
>> John
>>
>>
>
>
|