ComponentOne True DBGrid for .NET (2.0) Search HelpCentral 

C1TrueDBGrid.RowTop Method

Returns the Y coordinate of the top of a visible row.

[Visual Basic]

Public Function RowTop( _

ByVal row As Integer _

) As Integer

[C#]

public int RowTop(

int row

);

[Delphi]

public function RowTop(

row: Int32

): Int32;

Parameters

row

The displayed row index.

Return Value

The Y coordinate of the specified display row, based on the client coordinates of the grid.

Remarks

Allowable values for the row parameter range from 0 to VisibleRows - 1.

Use the RowTop method in conjunction with RowHeight, Left, and Width to determine the size and placement of controls displayed on top of a grid cell.

Example

The following code displays a C1TrueDBDropdown control when the grid is clicked, and the drop-down appears at the right edge of the current cell:

·      Visual Basic

       Private Sub C1TrueDBGrid1_ButtonClick(ByVal sender As Object, ByVal e As C1.Win.C1TrueDBGrid.ColEventArgs) Handles C1TrueDBGrid1.ButtonClick

           With Me.C1TrueDBDropdown1

               .Left = Me.C1TrueDBGrid1.Left + Me.C1TrueDBGrid1.RecordSelectorWidth + Me.C1TrueDBGrid1.Splits(0).DisplayColumns(0).Width + Me.C1TrueDBGrid1.Splits(0).DisplayColumns(1).Width

                .Top = Me.C1TrueDBGrid1.Top + Me.C1TrueDBGrid1.RowTop(Me.C1TrueDBGrid1.Row)

                .Visible = True

                .Select()

           End With

       End Sub

·      C#

       private void C1TrueDBGrid1_ButtonClick(object sender, C1.Win.C1TrueDBGrid.ColEventArgs e)

       {

           listBox1.Left = this.c1TrueDBGrid1.Left + this.c1TrueDBGrid1.RecordSelectorWidth + this.c1TrueDBGrid1.Splits[0].DisplayColumns[0].Width + this.c1TrueDBGrid1.Splits[0].DisplayColumns[1].Width;

           listBox1.Top = this.c1TrueDBGrid1.Top + this.c1TrueDBGrid1.RowTop(this.c1TrueDBGrid1.Row);

           listBox1.Visible = true;

           listBox1.Select();

       }

·      Delphi

       procedure TWinForm.c1TrueDBGrid1_ButtonClick(sender: System.Object; e: C1.Win.C1TrueDBGrid.ColEventArgs);

       begin

         ListBox1.Left := Self.C1TrueDBGrid1.Left + Self.C1TrueDBGrid1.RecordSelectorWidth + Self.C1TrueDBGrid1.Splits[0].DisplayColumns[0].Width + Self.C1TrueDBGrid1.Splits[0].DisplayColumns[1].Width + Self.C1TrueDBGrid1.Splits[0].DisplayColumns[2].Width;

         ListBox1.Top := Self.C1TrueDBGrid1.Top + Self.C1TrueDBGrid1.RowTop(Self.C1TrueDBGrid1.Row);

         ListBox1.Visible := True;

         ListBox1.Select;

       end;

See Tutorial 9 - Attaching an Arbitrary Drop-Down Control to a Grid Cell to see this code used within an application.

See Also

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


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