ComponentOne True DBGrid for .NET (2.0) Search HelpCentral 

C1TrueDBDropdown.UnboundColumnFetch Event

Occurs when the grid needs to display the value of a cell in an unbound column.

[Visual Basic]

Public Event UnboundColumnFetch As UnboundColumnFetchEventHandler

[C#]

public event UnboundColumnFetchEventHandler UnboundColumnFetch

[Delphi]

public property UnboundColumnFetch: UnboundColumnFetchEventHandler read remove_UnboundColumnFetch write add_UnboundColumnFetch;

Remarks

For a bound grid, any column with an empty C1DataColumn.DataField property and a non-empty C1DataColumn.Caption property is considered an unbound column.

To return an unbound value to the grid, simply set the UnboundColumnFetchEventArgs.Value property to the desired result. If a value is not assigned, the cell will remain blank.

Use this event to implement calculated fields based on other columns or to display local data alongside remote bound data.

The application is responsible for storing data entered into an unbound column by the user. Use the C1DataColumn object's C1DataColumn.Text property to retrieve unbound values within the C1TrueDBGrid.BeforeUpdate and C1TrueDBGrid.BeforeInsert events.

If an unbound column is used to display a calculated result based on other columns, then the unbound values do not need to be stored since they can always be calculated "on the fly" using either the C1DataColumn object's C1DataColumn.Text property or data access objects.

Note: During the execution of this event, row movement is not permitted.

Example

The following code code uses dtCopy, a global DataTable, to gather values to place into the unbound column, then sets these values equal to e.Value, placing the value into an unbound column:

·      Visual Basic

       Dim dtCopy as DataTable = New DataTable

       Private Sub C1TrueDBDropdown1_UnboundColumnFetch(ByVal sender As System.Object, ByVal e As C1.Win.C1TrueDBGrid.UnboundColumnFetchEventArgs) Handles C1TrueDBDropdown1.UnboundColumnFetch

           If e.Col = 0 And e.Row < dtCopy.Rows.Count Then

              e.Value = dtCopy.Rows(e.Row).Item("FirstName") & " " & dtCopy.Rows(e.Row).Item("LastName")

           End If

       End Sub

·      C#

       DataTable dtCopy = new DataTable;

       private void c1TrueDBDropdown1_UnboundColumnFetch( System.object sender, C1.Win.C1TrueDBGrid.UnboundColumnFetchEventArgs e)

       {

           if ( e.Col == 0 & e.Row < dtCopy.Rows.Count )

           {

               e.value = dtCopy.Rows[e.Row].["FirstName"] + " " + dtCopy.Rows[e.Row] ["LastName"];

           }

       }

·      Delphi

       var dtCopy: DataTable;

         dtCopy := DataTable.Create;

       procedure TWinForm.C1TrueDBDropdown1_UnboundColumnFetch(sender: System.Object; e: C1.Win.C1TrueDBGrid.UnboundColumnFetchEventArgs);

       begin

         if((e.Col = 0) and (e.Row < dtCopy.Rows.Count)) then

           e.Value := dtCopy.Rows[e.Row]['FirstName'].ToString + ' ' + dtCopy.Rows[e.Row]['LastName'].ToString;

       end;

See Also

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


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