ComponentOne True DBGrid for .NET (2.0) Search HelpCentral 

C1TrueDBGrid.RowColChange Event

Occurs when the focus moves to a different cell.

[Visual Basic]

Public Event RowColChange As RowColChangeEventHandler

[C#]

public event RowColChangeEventHandler RowColChange

[Delphi]

public property RowColChange: RowColChangeEventHandler read remove_RowColChange write add_RowColChange;

Remarks

This event is triggered under several circumstances:

·      When the grid is first displayed.

·      When the user moves the current cell by clicking another cell or using the navigation keys.

·      When data in the grid is changed in a way that implicitly affects the current row, such as when the current row is deleted when it is the last row in the grid.

·      When the Bookmark, Row, Col, or SplitIndex properties are changed in code to a different value.

The current cell position is provided by the Bookmark and Col properties. The previous cell position is specified by the RowColChangeEventArgs.LastRow and RowColChangeEventArgs.LastCol properties.

If the user edits data and then moves the current cell position to a new row, the update events for the original row are completed before another cell becomes the current cell.

If a cell change also results in a change to the current split, then the SplitChange event will always precede the RowColChange event.

Example

The following code sets the state of the expand/collapse radio buttons on row change:

·      Visual Basic

       Private Sub C1TrueDBGrid1_RowColChange(ByVal sender As Object, ByVal e As C1.Win.C1TrueDBGrid.RowColChangeEventArgs) Handles C1TrueDBGrid1.RowColChange

           ' Get the type/state of the row.

           Dim rtype As C1.Win.C1TrueDBGrid.RowTypeEnum = Me.C1TrueDBGrid1.Splits(0).Rows(Me.C1TrueDBGrid1.Row).RowType

           Select Case rtype

               Case C1.Win.C1TrueDBGrid.RowTypeEnum.CollapsedGroupRow

                   Me.radioButton2.Checked = True

               Case C1.Win.C1TrueDBGrid.RowTypeEnum.ExpandedGroupRow

                   Me.radioButton1.Checked = True

           End Select

       End Sub

·      C#

       private void c1TrueDBGrid1_RowColChange(object sender, C1.Win.C1TrueDBGrid.RowColChangeEventArgs e)

       {

           // Get the type/state of the row.

           C1.Win.C1TrueDBGrid.RowTypeEnum rtype = this.c1TrueDBGrid1.Splits[0].Rows[this.c1TrueDBGrid1.Row].RowType;

           switch (rtype)

           {

               case C1.Win.C1TrueDBGrid.RowTypeEnum.CollapsedGroupRow:

                   this.radioButton2.Checked = true;

                   break;

               case C1.Win.C1TrueDBGrid.RowTypeEnum.ExpandedGroupRow:

                   this.radioButton1.Checked = true;

                   break;

           }

       }

·      Delphi

       procedure C1TrueDBGrid1_RowColChange(sender: System.Object; e: C1.Win.C1TrueDBGrid.RowColChangeEventArgs);

       var

         rtype : C1.Win.C1TrueDBGrid.RowTypeEnum;

       begin

         // Get the type/state of the row.

         rtype := Self.C1TrueDBGrid1.Splits[0].Rows[Self.c1TrueDBGrid1.Row].RowType;

         case rtype of

           C1.Win.C1TrueDBGrid.RowTypeEnum.CollapsedGroupRow:

           begin 

             Self.RadioButton2.Checked := True;

             Exit;

           end;

           C1.Win.C1TrueDBGrid.RowTypeEnum.ExpandedGroupRow):

           begin

             Self.RadioButton1.Checked := True;

             Exit;

           end;

         end;

       end;

For a full example using the RowColChange event, see the ToggleGroupRows sample located on http://helpcentral.componentone.com/ProductResources.aspx.

See Also

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


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