첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

▶ XAML

<dxg:GridControl x:Name="gridControl">
    <dxg:GridControl.Columns>
        <dxg:GridColumn
            FieldName="UserName"
            Header="User Name" />
        <dxg:GridColumn
            FieldName="RegistrationDate"
            Header="Registration Date" />
    </dxg:GridControl.Columns>
    <dxg:GridControl.View>
        <dxg:TableView x:Name="tableView">
            <dxg:TableView.RowCellMenuCustomizations>
                <dxb:BarButtonItem x:Name="deleteRowBarButtonItem"
                    Content="Delete Row" 
                    ItemClick="deleteRowBarButtonItem_ItemClick" />
                <dxb:BarButtonItem x:Name="copyCellDataBarButtonItem"
                    Content="Copy Cell Data" 
                    ItemClick="copyCellDataBarButtonItem_ItemClick" />
            </dxg:TableView.RowCellMenuCustomizations>
        </dxg:TableView>
    </dxg:GridControl.View>
</dxg:GridControl>

 

728x90

 

▶ C#

using DevExpress.Xpf.Bars;
using DevExpress.Xpf.Grid;

#region Delete Row 바 버튼 항목 항목 클릭시 처리하기 - deleteRowBarButtonItem_ItemClick(sender, e)

/// <summary>
/// Delete Row 바 버튼 항목 항목 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void deleteRowBarButtonItem_ItemClick(object sender, ItemClickEventArgs e)
{
    GridCellMenuInfo gridCellMenuInfo = this.tableView.GridMenu.MenuInfo as GridCellMenuInfo;

    if(gridCellMenuInfo != null && gridCellMenuInfo.Row != null)
    {
        int rowHandle = gridCellMenuInfo.Row.RowHandle.Value;

        this.tableView.DeleteRow(rowHandle);
    }
}

#endregion

#region Copy Cell Data 바 버튼 항목 항목 클릭시 처리하기 - copyCellDataBarButtonItem_ItemClick(sender, e)

/// <summary>
/// Copy Cell Data 바 버튼 항목 항목 클릭시 처리하기
/// </summary>
/// <param name="sender">이벤트 발생자</param>
/// <param name="e">이벤트 인자</param>
private void copyCellDataBarButtonItem_ItemClick(object sender, ItemClickEventArgs e)
{
    GridCellMenuInfo gridCellMenuInfo = this.tableView.GridMenu.MenuInfo as GridCellMenuInfo;

    if(gridCellMenuInfo != null && gridCellMenuInfo.Row != null)
    {
        int        rowHandle  = gridCellMenuInfo.Row.RowHandle.Value;
        GridColumn gridColumn = gridCellMenuInfo.Column as GridColumn;

        object cellValue = this.gridControl.GetCellValue(rowHandle, gridColumn);

        Clipboard.SetText(cellValue == null ? string.Empty : cellValue.ToString());
    }
}

#endregion

 

728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요