Re: DataGrid & Winform Issues

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Kevin Earley (kearley_at_sosnc.com)
Date: 06/30/04


Date: Wed, 30 Jun 2004 12:46:15 -0400

I think I had a problem similar to #3. The update worked fine with a
button, but not when I called it when the user clicked the plus sign. I had
to get off the new row in my grid to get the update to work properly.
oHit = dgEvents.HitTest(e.X, e.Y)

iCurrentRow = oHit.Row

If oHit.Column = -1 Then

    mbPlusClick = True

            If UCase(dgEvents.DataMember) = "EVENTLOG" Then

                'Update the Add New Row to allow adding child recors

                If iCurrentRow =
dgEvents.DataSource.Tables("eventLog").rows.count Then

                    'get off the new ro to allow update

                    dgEvents.CurrentRowIndex = iCurrentRow - 1

                    UpdateEventLog()

                    'Get back to the new row

                    dgEvents.CurrentRowIndex = iCurrentRow

            End If

"Vinil Menon" <vinilm@hotmail.com> wrote in message
news:eshEfYSXEHA.1000@TK2MSFTNGP12.phx.gbl...
> I am developing an application in C# using WinForms. The application is
> designed to have multiple grids as the dataset has a (Parent - Child-Grand
> Child ) relationship. Following are the problems faced by me Problem
1:I've
> just tried this with a couple of tables related to each other
> (Parent-Child-GrandChild) and it's acting a bit odd.If I delete a row in
the
> Parent Table and call RejectChanges in the RowDeleted the row doesn't
> disappear, but the last row in the grid does (aslong as the last row is
> visible at the time of delete), if I re-sort the grid the last row
> re-appears. I am pasting the code with I have written on Row Deleted
> eventprivate void Resource_RowDeleted(object sender,
DataRowChangeEventArgs
> e)
>
> {
>
> DataRowChangeEventArgs dre;
>
> dre = new DataRowChangeEventArgs(e.Row, DataRowAction.Rollback);
>
> e.Row.RejectChanges();
>
> e.Row.RowError = "Cannot DELETE the Resource";
>
> e = dre; }
>
> Also I have seen may posts with the same question but none of them have an
> answer to this problem.
>
> Problem 2:
>
> In my scenario I have created the DataRelation between all the tables in
the
> dataset. Now I would like one of the grids to have the feature where the
row
> is not allowed to be deleted . Is there any way of doing it. I have
written
> the following code to achieve it but with no success
>
> CurrencyManager cm =
> (CurrencyManager)this.BindingContext[dgSegments.DataSource,
> dgSegments.DataMember];
>
> ((DataView)cm.List).AllowNew = false;
>
> ((DataView)cm.List).AllowDelete = false;
>
> Is there any other way of doing it ????
>
> Problem 3
>
> My scenario has a MDI Child forms. I am facing a starge problem. I have
data
> save logic written on button click. I ported the same logic onto Menu
click.
> To my surprise when I call the same Save function to get the changes for a
> table I am not able to get any changes despite my modification the the row
> of the table. At the same time the same function when called from the
button
> click gets the changes
>
> The code use to get the changes made to the specific table is
> combds.Tables["Phases"].GetChanges()
>
> Is there any difference in the call made by menu and a button control on
> Form ????
>
>
>
>


Quantcast