다음을 통해 공유


DataGridCell.ColumnNumber 속성

정의

DataGrid 컨트롤의 열 번호를 가져오거나 설정합니다.

public:
 property int ColumnNumber { int get(); void set(int value); };
public int ColumnNumber { get; set; }
member this.ColumnNumber : int with get, set
Public Property ColumnNumber As Integer

속성 값

Int32

열 번호입니다.

예제

다음 예제에서는 CurrentCell 의 속성을 System.Windows.Forms.DataGridDataGridCell합니다. 에 저장 된 값을 DataTable 지정 하 여 반환 됩니다 DataRowDataColumn 를 통해 개체를 RowNumberColumnNumber 속성입니다.

void PrintCell( Object^ sender, MouseEventArgs^ /*e*/ )
{
   DataGrid^ thisGrid = dynamic_cast<DataGrid^>(sender);
   DataGridCell myDataGridCell = thisGrid->CurrentCell;
   BindingManagerBase^ bm = BindingContext[ thisGrid->DataSource,thisGrid->DataMember ];
   DataRowView^ drv = dynamic_cast<DataRowView^>(bm->Current);
   Console::WriteLine( drv[ myDataGridCell.ColumnNumber ] );
   Console::WriteLine( myDataGridCell.RowNumber );
}
private void PrintCell(object sender, MouseEventArgs e)
{
   DataGrid thisGrid = (DataGrid) sender;
   DataGridCell myDataGridCell = thisGrid.CurrentCell;
   BindingManagerBase bm = BindingContext[thisGrid.DataSource, thisGrid.DataMember];
   DataRowView drv = (DataRowView) bm.Current;
   Console.WriteLine(drv [myDataGridCell.ColumnNumber]);
   Console.WriteLine(myDataGridCell.RowNumber);
}
Private Sub PrintCell(sender As Object, e As MouseEventArgs)
   Dim thisGrid As DataGrid = CType(sender, DataGrid)
   Dim myDataGridCell As DataGridCell = thisGrid.CurrentCell
   Dim bm As BindingManagerBase = _
   BindingContext (thisGrid.DataSource, thisGrid.DataMember)
   Dim drv As DataRowView = CType(bm.Current, DataRowView)
   Console.WriteLine(drv(myDataGridCell.ColumnNumber))
   Console.WriteLine(myDataGridCell.RowNumber)
End Sub

설명

사용할 수 있습니다를 ColumnNumber 지정할 값을 DataColumnDataTable 연관를 System.Windows.Forms.DataGrid 컨트롤.

적용 대상

추가 정보