DataGridTableStyle.AllowSorting 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
이 DataGridTableStyle을 사용할 때 모눈 테이블 정렬이 허용되는지 여부를 나타냅니다.
public:
property bool AllowSorting { bool get(); void set(bool value); };
public bool AllowSorting { get; set; }
member this.AllowSorting : bool with get, set
Public Property AllowSorting As Boolean
속성 값
정렬이 허용되면 true
이고, 그렇지 않으면 false
입니다. 기본값은 true
입니다.
예제
다음 코드 예제에서는 단추를 클릭하여 정렬 가용성 DataGrid 을 토글할 수 있으며 현재 정렬 상태가 레이블에 표시됩니다. 이 예제에서는 일부 데이터, Button a System.Data.DataSet DataGrid 및 Label on을 포함하는 with aForm가 있어야 합니다.
private:
void DataGridTableStyle_Sample_Load( Object^ /*sender*/, EventArgs^ /*e*/ )
{
myDataGridTableStyle1 = gcnew DataGridTableStyle;
mylabel->Text = String::Concat( "Sorting Status : ", myDataGridTableStyle1->AllowSorting );
if ( myDataGridTableStyle1->AllowSorting == true )
{
btnApplyStyles->Text = "Remove Sorting";
}
else
{
btnApplyStyles->Text = "Apply Sorting";
}
myDataGridTableStyle1->AllowSortingChanged += gcnew System::EventHandler(
this, &DataGridTableStyle_Sample::AllowSortingChanged_Handler );
myDataGridTableStyle1->MappingName = "Customers";
}
void AllowSortingChanged_Handler( Object^ /*sender*/, EventArgs^ /*e*/ )
{
mylabel->Text = String::Concat( "Sorting Status : ", myDataGridTableStyle1->AllowSorting );
}
void btnApplyStyles_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
if ( myDataGridTableStyle1->AllowSorting == true )
{
// Remove sorting.
myDataGridTableStyle1->AllowSorting = false;
btnApplyStyles->Text = "Allow Sorting";
}
else
{
// Allow sorting.
myDataGridTableStyle1->AllowSorting = true;
btnApplyStyles->Text = "Remove Sorting";
}
mylabel->Text = String::Concat( "Sorting Status : ", myDataGridTableStyle1->AllowSorting );
// Add the DataGridTableStyle to DataGrid.
myDataGrid->TableStyles->Add( myDataGridTableStyle1 );
}
private void DataGridTableStyle_Sample_Load(object sender,
EventArgs e)
{
myDataGridTableStyle1 = new DataGridTableStyle();
mylabel.Text = "Sorting Status :" +
myDataGridTableStyle1.AllowSorting.ToString();
if(myDataGridTableStyle1.AllowSorting == true)
{
btnApplyStyles.Text = "Remove Sorting";
}
else
{
btnApplyStyles.Text = "Apply Sorting";
}
// Attach custom event handlers.
myDataGridTableStyle1.AllowSortingChanged +=
new System.EventHandler(AllowSortingChanged_Handler);
myDataGridTableStyle1.MappingName = "Customers";
}
private void AllowSortingChanged_Handler(object sender,EventArgs e)
{
mylabel.Text = "Sorting Status :"
+ myDataGridTableStyle1.AllowSorting.ToString();
}
private void btnApplyStyles_Click(object sender, EventArgs e)
{
if(myDataGridTableStyle1.AllowSorting == true)
{
// Remove sorting.
myDataGridTableStyle1.AllowSorting = false;
btnApplyStyles.Text = "Allow Sorting";
}
else
{
// Allow sorting.
myDataGridTableStyle1.AllowSorting = true;
btnApplyStyles.Text = "Remove Sorting";
}
mylabel.Text = "Sorting Status :" + myDataGridTableStyle1.AllowSorting;
// Add the DataGridTableStyle to DataGrid.
myDataGrid.TableStyles.Add(myDataGridTableStyle1);
}
Private Sub DataGridTableStyle_Sample_Load(ByVal sender As Object, _
ByVal e As EventArgs) Handles MyBase.Load
myDataGridTableStyle1 = New DataGridTableStyle()
mylabel.Text = "Sorting Status :" + myDataGridTableStyle1.AllowSorting.ToString()
If myDataGridTableStyle1.AllowSorting = True Then
btnApplyStyles.Text = "Remove Sorting"
Else
btnApplyStyles.Text = "Apply Sorting"
End If
' Attach custom event handlers.
AddHandler myDataGridTableStyle1.AllowSortingChanged, AddressOf AllowSortingChanged_Handler
myDataGridTableStyle1.MappingName = "Customers"
End Sub
Private Sub AllowSortingChanged_Handler(ByVal sender As Object, ByVal e As EventArgs)
mylabel.Text = "Sorting Status :" + myDataGridTableStyle1.AllowSorting.ToString()
End Sub
Private Sub btnApplyStyles_Click(ByVal sender As Object, _
ByVal e As EventArgs) Handles btnApplyStyles.Click
If myDataGridTableStyle1.AllowSorting = True Then
' Remove sorting.
myDataGridTableStyle1.AllowSorting = False
btnApplyStyles.Text = "Allow Sorting"
Else
' Allow sorting.
myDataGridTableStyle1.AllowSorting = True
btnApplyStyles.Text = "Remove Sorting"
End If
mylabel.Text = "Sorting Status :" + myDataGridTableStyle1.AllowSorting.ToString
' Add the DataGridTableStyle to DataGrid.
myDataGrid.TableStyles.Add(myDataGridTableStyle1)
End Sub
설명
속성이 AllowSorting 설정 true
되면 각 열 머리글에 정렬 방향을 나타내는 삼각형이 나타납니다. 사용자는 열 머리글을 클릭하여 해당 열별로 표를 정렬할 수 있습니다. 열을 두 번째로 클릭하면 정렬 방향이 변경되었습니다.
이 속성은 속성을 재정의 DataGrid.AllowSorting 합니다.