ComponentOne True DBGrid for .NET (2.0) Search HelpCentral 

C1TrueDBGrid.BeforeClose Event

Occurs when the user attempts to close a child grid.

[Visual Basic]

Public Event BeforeClose As CancelEventHandler

[C#]

public event CancelEventHandler BeforeClose

[Delphi]

public property BeforeClose: CancelEventHandler read remove_BeforeClose write add_BeforeClose;

Remarks

If the event procedure sets the CancelEventArgs.Cancel property to True, the cell will not enter edit mode. Otherwise, the ColEdit event is raised immediately, followed by the Change event for KeyAscii, if non-zero.

Use this event to control the editability of cells on a per-cell basis.

Note: KeyAscii can only be 0 if a floating editor marquee is not in use.

Example

The following code uses the BeforeClose event to show the message "Do you want to close this record?" before a child grid is closed:

·      Visual Basic

       Private Sub C1TrueDBGrid1_BeforeClose(ByVal sender As System.Object, ByVal e As C1.Win.C1TrueDBGrid.CancelEventArgs) Handles C1TrueDBGrid1.BeforeClose

           If MessageBox.Show("Do you want to close this record?", "C1TrueDBGrid", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then

              e.Cancel = True

           End If

       End Sub

·      C#

       private void c1TrueDBGrid1_BeforeClose(object sender, C1.Win.C1TrueDBGrid.CancelEventArgs e)

       {

           if (MessageBox.Show("Do you want to close this record?", "C1TrueDBGrid", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)

           {

               e.Cancel = true;

           }

       }

·      Delphi

       procedure C1TrueDBGrid_BeforeClose(sender: System.Object; e: C1.Win.C1TrueDBGrid.CancelEventArgs);

       begin

         if (MessageBox.Show('Do you want to close this record?', 'C1TrueDBGrid', MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.No) then

           e.Cancel := True;

       end;

Note: The C1TrueDBGrid control must have a ChildGrid property set for this event to be raised.

See Also

C1TrueDBGrid Class | C1TrueDBGrid Members | C1.Win.C1TrueDBGrid Namespace


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.