■ GridControl 클래스의 GroupSummary 속성을 사용해 GROUP SUMMARY를 설정하는 방법을 보여준다. ▶ 예제 코드 (XAML)
|
<dxg:GridControl x:Name="gridControl" AutoGenerateColumns="AddNew"> <dxg:GridControl.View> <dxg:TableView /> </dxg:GridControl.View> </dxg:GridControl> |
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
using DevExpress.Data; using DevExpress.Xpf.Grid; ... #region GROUP SUMMARY 생성하기 - CreateGroupSummary() /// <summary> /// GROUP SUMMARY 생성하기 /// </summary> private void CreateGroupSummary() { this.gridControl.GroupSummary.Add ( new GridSummaryItem() { FieldName = "Age", SummaryType = SummaryItemType.Min } ); this.gridControl.GroupSummary.Add ( new GridSummaryItem() { FieldName = "Age", SummaryType = SummaryItemType.Max } ); } #endregion ... this.gridControl.ItemsSource = new AccountList().GetData(); this.gridControl.GroupBy(this.gridControl.Columns["Married"], ColumnSortOrder.Ascending); CreateGroupSummary(); |
■ GridControl 엘리먼트의 GroupSummary 속성을 사용해 GROUP SUMMARY를 설정하는 방법을 보여준다. ▶ 예제 코드 (XAML)
|
<dxg:GridControl x:Name="gridControl" AutoGenerateColumns="AddNew"> <dxg:GridControl.View> <dxg:TableView /> </dxg:GridControl.View> <dxg:GridControl.GroupSummary> <dxg:GridSummaryItem FieldName="Age" SummaryType="Min" /> <dxg:GridSummaryItem FieldName="Age" SummaryType="Max" /> </dxg:GridControl.GroupSummary> </dxg:GridControl> |
▶ 예제 코드 (C#)
|
using DevExpress.Data; ... this.gridControl.ItemsSource = new AccountList().GetData(); this.gridControl.GroupBy(this.gridControl.Columns["Married"], ColumnSortOrder.Ascending); |
■ GridControl 클래스의 TotalSummary 속성을 사용해 TOTAL SUMMARY를 설정하는 방법을 보여준다. ▶ 예제 코드 (XAML)
|
<dxg:GridControl x:Name="gridControl" AutoGenerateColumns="AddNew"> <dxg:GridControl.View> <dxg:TableView ShowTotalSummary="True" /> </dxg:GridControl.View> </dxg:GridControl> |
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
using DevExpress.Data; using DevExpress.Xpf.Grid; #region TOTAL SUMMARY 생성하기 - CreateTotalSummary() /// <summary> /// TOTAL SUMMARY 생성하기 /// </summary> private void CreateTotalSummary() { this.gridControl.TotalSummary.Add ( new GridSummaryItem() { FieldName = "UserName", SummaryType = SummaryItemType.Count, DisplayFormat = "Total Users : {0}" } ); this.gridControl.TotalSummary.Add ( new GridSummaryItem() { FieldName = "Age", SummaryType = SummaryItemType.Min } ); this.gridControl.TotalSummary.Add ( new GridSummaryItem() { FieldName = "Age", SummaryType = SummaryItemType.Max } ); } #endregion |
■ GridControl 엘리먼트의 TotalSummary 속성을 사용해 TOTAL SUMMARY를 설정하는 방법을 보여준다. ▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
<dxg:GridControl x:Name="gridControl" AutoGenerateColumns="AddNew"> <dxg:GridControl.TotalSummary> <dxg:GridSummaryItem FieldName="UserName" SummaryType="Count" DisplayFormat="Total Users : {0}" /> <dxg:GridSummaryItem FieldName="Age" SummaryType="Min" /> <dxg:GridSummaryItem FieldName="Age" SummaryType="Max" /> </dxg:GridControl.TotalSummary> <dxg:GridControl.View> <dxg:TableView ShowTotalSummary="True" /> </dxg:GridControl.View> </dxg:GridControl> |
■ DataViewBase 클래스의 CellStyle 속성을 사용해 선택한 셀 모양을 변경하는 방법을 보여준다. ▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
<Window.Resources> <Style x:Key="CellStyleKey" TargetType="dxg:CellContentPresenter"> <Style.Triggers> <Trigger Property="SelectionState" Value="Selected"> <Setter Property="Background" Value="Red" /> </Trigger> <Trigger Property="SelectionState" Value="Focused"> <Setter Property="Background" Value="Green" /> <Setter Property="TextBlock.Foreground" Value="Pink" /> </Trigger> <Trigger Property="SelectionState" Value="FocusedAndSelected"> <Setter Property="Background" Value="Gray" /> <Setter Property="TextBlock.Foreground" Value="Black" /> </Trigger> </Style.Triggers> </Style> <Style x:Key="FocusedRowStyle" TargetType="dxg:GridRowContent"> <Style.Triggers> <Trigger Property="dxg:GridViewBase.IsFocusedRow" Value="True"> <Setter Property="Background" Value="Gray" /> <Setter Property="Foreground" Value="White" /> </Trigger> </Style.Triggers> </Style> </Window.Resources> <Grid> <dxg:GridControl x:Name="gridControl" AutoGenerateColumns="AddNew" SelectionMode="Cell"> <dxg:GridControl.View> <dxg:TableView ShowGroupPanel="False" AllowGrouping="False" CellStyle="{StaticResource CellStyleKey}"> </dxg:TableView> </dxg:GridControl.View> </dxg:GridControl> </Grid> |
■ GridViewBase 클래스의 CopyingToClipboard 이벤트를 사용해 클립보드에 복사할 경우 처리하는 방법을 보여준다. (행 값이 클립보드에 복사되기 전 처리하기) ▶ 예제 코드 (C#)
더 읽기
■ DataViewCommandsBase 클래스의 DeleteFocusedRow 속성을 사용해 포커스 행을 삭제하는 방법을 보여준다. ▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
<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 Content="Delete Row" Command="{x:Static dxg:GridCommands.DeleteFocusedRow}" /> </dxg:TableView.RowCellMenuCustomizations> </dxg:TableView> </dxg:GridControl.View> </dxg:GridControl> |
■ TableView 엘리먼트의 행/셀 컨텍스트 메뉴에서 셀 값 복사하는 방법을 보여준다. ▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
<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> |
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
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 |
■ TableView 엘리먼트의 행/셀 컨텍스트 메뉴에서 행을 삭제하는 방법을 보여준다. ▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
<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> |
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
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 |
■ DataViewBase 클래스의 RowCellMenuCustomizations 속성을 사용해 행/셀 컨텍스트 메뉴를 설정하는 방법을 보여준다. ▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
<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> |
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
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 |
■ TableView 클래스의 InitNewRow 이벤트를 사용해 새 항목 행을 초기화하는 방법을 보여준다. ▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
using DevExpress.Xpf.Grid; ... #region 테이블 뷰 신규 행 초기화시 처리하기 - tableView_InitNewRow(sender, e) /// <summary> /// 테이블 뷰 신규 행 초기화시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void tableView_InitNewRow(object sender, InitNewRowEventArgs e) { this.gridControl.SetCellValue(e.RowHandle, "UnitPrice" , 10 ); this.gridControl.SetCellValue(e.RowHandle, "Discontinued", false); this.gridControl.SetCellValue(e.RowHandle, "UnitsOnOrder", 1 ); } #endregion |
■ GridViewBase 클래스의 InvalidRowException 이벤트를 사용해 검증 실패시 처리하는 방법을 보여준다. ▶ 예제 #1 : IDXDataErrorInfo 인터페이스를 구현한 경우 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
using DevExpress.Xpf.Grid; ... #region 테이블 뷰 적절치 못한 행 예외 처리하기 - tableView_InvalidRowException(sender, e) /// <summary> /// 테이블 뷰 적절히 못한 행 예외 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void tableView_InvalidRowException(object pSender, InvalidRowExceptionEventArgs e) { e.ExceptionMode = ExceptionMode.NoAction; } #endregion |
▶
더 읽기
■ GridViewBase 클래스의 ValidateRow 이벤트를 사용해 행을 검증하는 방법을 보여준다. ▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
using System; using DevExpress.Xpf.Grid; ... #region 테이블 뷰 행 검증하기 - tableView_ValidateRow(sender, e) /// <summary> /// 테이블 뷰 행 검증하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void tableView_ValidateRow(object sender, GridRowValidationEventArgs e) { DateTime startDate = (e.Row as Task).StartDate; DateTime endDate = (e.Row as Task).EndDate; e.IsValid = startDate < endDate; } #endregion |
■ GridViewBase 클래스의 HiddenEditor 이벤트를 사용해 에디터가 숨겨진 후 처리하는 방법을 보여준다. ▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
using DevExpress.Xpf.Grid; ... #region 테이블 뷰 에디터 숨겨진 후 처리하기 - tableView_HiddenEditor(sender, e) /// <summary> /// 테이블 뷰 에디터 숨겨진 후 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void tableView_HiddenEditor(object sender, EditorEventArgs e) { if(e.Column.FieldName != "Discontinued") { return; } this.tableView.CommitEditing(); } #endregion |
■ GridColumn 클래스의 Validate 이벤트를 사용해 컬럼 값을 검증하는 방법을 보여준다. ▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
using System; using DevExpress.Xpf.Grid; ... #region 단가 그리드 컬럼 값 검증하기 - unitPriceGridColumn_Validate(sender, e) /// <summary> /// 단가 그리드 컬럼 값 검증하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void unitPriceGridColumn_Validate(object sender, GridCellValidationEventArgs e) { Product product = e.Row as Product; if(product == null) { return; } bool discontinued = product.Discontinued; if(discontinued) { double newValue = Convert.ToDouble(pGridCellValidationEventArgs.Value ); double cellValue = Convert.ToDouble(pGridCellValidationEventArgs.CellValue); double discount = 100d - (newValue * 100) / cellValue; if(!(e.IsValid = dDiscount > 0 && discount <= 30d)) { e.ErrorType = DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical; if(discount < 0) { e.ErrorContent = string.Format ( "The price cannot be greater than ${0}", Convert.ToDouble(e.CellValue) ); return; } e.ErrorContent = string.Format ( "The discount cannot be greater than 30% (${0}). Please correct the price.", Convert.ToDouble(e.CellValue) * 0.7 ); } } } #endregion |
※ 코드로 셀 값 변경시 상기
더 읽기
■ GridColumn 엘리먼트의 EditTemplate 속성을 사용해 컬럼 값 편집용 커스텀 에디터를 정의하는 ControlTemplate를 설정하는 방법을 보여준다. ▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
<dxg:GridColumn FieldName="OrderUnit"> <dxg:GridColumn.DisplayTemplate> <ControlTemplate> <ProgressBar Margin="2" Minimum="0" Maximum="50" Value="{Binding Path=DisplayText, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" /> </ControlTemplate> </dxg:GridColumn.DisplayTemplate> <dxg:GridColumn.EditTemplate> <ControlTemplate> <Grid VerticalAlignment="Center"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="30" /> </Grid.ColumnDefinitions> <Slider x:Name="PART_Editor" Grid.Column="0" Minimum="0" Maximum="50" Value="{Binding Path=EditValue, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource IntegerToDoubleValueConverterKey}}" /> <TextBlock Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black" TextWrapping="NoWrap" Text="{Binding EditValue, RelativeSource={RelativeSource TemplatedParent}}" /> </Grid> </ControlTemplate> </dxg:GridColumn.EditTemplate> </dxg:GridColumn> |
■ ColumnBase 엘리먼트의 DisplayTemplate 속성을 사용해 컬럼 값 표시를 정의하는 ControlTemplate를 설정하는 방법을 보여준다. ▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
<dxg:GridColumn FieldName="OrderUnit"> <dxg:GridColumn.DisplayTemplate> <ControlTemplate> <ProgressBar Margin="2" Minimum="0" Maximum="50" Value="{Binding Path=DisplayText, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" /> </ControlTemplate> </dxg:GridColumn.DisplayTemplate> <dxg:GridColumn.EditTemplate> <ControlTemplate> <Grid VerticalAlignment="Center"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="30" /> </Grid.ColumnDefinitions> <Slider x:Name="PART_Editor" Grid.Column="0" Minimum="0" Maximum="50" Value="{Binding Path=EditValue, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource IntegerToDoubleValueConverterKey}}" /> <TextBlock Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black" TextWrapping="NoWrap" Text="{Binding EditValue, RelativeSource={RelativeSource TemplatedParent}}" /> </Grid> </ControlTemplate> </dxg:GridColumn.EditTemplate> </dxg:GridColumn> |
■ GridColumn 엘리먼트의 EditSettings 속성을 사용해 SpinEditSettings를 설정하는 방법을 보여준다. ▶ 예제 코드 (XAML)
|
<dxg:GridColumn FieldName="UnitPrice"> <dxg:GridColumn.EditSettings> <dxe:SpinEditSettings MinValue="1" MaxValue="999" /> </dxg:GridColumn.EditSettings> </dxg:GridColumn> |
■ DataViewBase 엘리먼트의 DetailHeaderContent 속성을 사용해 상세 뷰 헤더 콘텐트를 설정하는 방법을 보여준다. ▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
<dxg:GridControl x:Name="gridControl" AutoGenerateColumns="AddNew"> <dxg:GridControl.View> <dxg:TableView ShowGroupPanel="False" AutoWidth="False" DetailHeaderContent="Employee" /> </dxg:GridControl.View> <dxg:GridControl.DetailDescriptor> <dxg:TabViewDetailDescriptor> <dxg:TabViewDetailDescriptor.DetailDescriptors> <dxg:DataControlDetailDescriptor ItemsSourcePath="OrderList"> <dxg:DataControlDetailDescriptor.DataControl> <dxg:GridControl AutoGenerateColumns="AddNew"> <dxg:GridControl.View> <dxg:TableView ShowGroupPanel="False" AutoWidth="False" DetailHeaderContent="Order" /> </dxg:GridControl.View> </dxg:GridControl> </dxg:DataControlDetailDescriptor.DataControl> </dxg:DataControlDetailDescriptor> <dxg:ContentDetailDescriptor ContentTemplate="{StaticResource NoteDataTemplateKey}" HeaderContent="Note"> </dxg:ContentDetailDescriptor> </dxg:TabViewDetailDescriptor.DetailDescriptors> </dxg:TabViewDetailDescriptor> </dxg:GridControl.DetailDescriptor> </dxg:GridControl> |
※ xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid
■ GridColumn 엘리먼트의 EditSettings 속성을 사용해 ComboBoxEditSettings를 설정하는 방법을 보여준다. ▶ 예제 코드 (XAML)
|
<dxg:GridColumn FieldName="ProductName"> <dxg:GridColumn.EditSettings> <dxe:ComboBoxEditSettings x:Name="comboBoxEditSettings" ValueMember="ProductName" DisplayMember="ProductName" /> </dxg:GridColumn.EditSettings> </dxg:GridColumn> |
■ ContentDetailDescriptor 엘리먼트를 사용하는 방법을 보여준다. ▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
<dxg:GridControl x:Name="gridControl" AutoGenerateColumns="AddNew"> <dxg:GridControl.View> <dxg:TableView ShowGroupPanel="False" AutoWidth="False" DetailHeaderContent="Employee" /> </dxg:GridControl.View> <dxg:GridControl.DetailDescriptor> <dxg:TabViewDetailDescriptor> <dxg:TabViewDetailDescriptor.DetailDescriptors> <dxg:DataControlDetailDescriptor ItemsSourcePath="OrderList"> <dxg:DataControlDetailDescriptor.DataControl> <dxg:GridControl AutoGenerateColumns="AddNew"> <dxg:GridControl.View> <dxg:TableView ShowGroupPanel="False" AutoWidth="False" DetailHeaderContent="Order" /> </dxg:GridControl.View> </dxg:GridControl> </dxg:DataControlDetailDescriptor.DataControl> </dxg:DataControlDetailDescriptor> <dxg:ContentDetailDescriptor ContentTemplate="{StaticResource NoteDataTemplateKey}" HeaderContent="Note"> </dxg:ContentDetailDescriptor> </dxg:TabViewDetailDescriptor.DetailDescriptors> </dxg:TabViewDetailDescriptor> </dxg:GridControl.DetailDescriptor> </dxg:GridControl> |
※ xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid
■ DataControlDetailDescriptor 엘리먼트를 사용하는 방법을 보여준다. ▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
<dxg:GridControl x:Name="gridControl" AutoGenerateColumns="AddNew"> <dxg:GridControl.View> <dxg:TableView ShowGroupPanel="False" AutoWidth="False" DetailHeaderContent="Employee" /> </dxg:GridControl.View> <dxg:GridControl.DetailDescriptor> <dxg:TabViewDetailDescriptor> <dxg:TabViewDetailDescriptor.DetailDescriptors> <dxg:DataControlDetailDescriptor ItemsSourcePath="OrderList"> <dxg:DataControlDetailDescriptor.DataControl> <dxg:GridControl AutoGenerateColumns="AddNew"> <dxg:GridControl.View> <dxg:TableView ShowGroupPanel="False" AutoWidth="False" DetailHeaderContent="Order" /> </dxg:GridControl.View> </dxg:GridControl> </dxg:DataControlDetailDescriptor.DataControl> </dxg:DataControlDetailDescriptor> <dxg:ContentDetailDescriptor ContentTemplate="{StaticResource NoteDataTemplateKey}" HeaderContent="Note"> </dxg:ContentDetailDescriptor> </dxg:TabViewDetailDescriptor.DetailDescriptors> </dxg:TabViewDetailDescriptor> </dxg:GridControl.DetailDescriptor> </dxg:GridControl> |
※ xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid
■ TabViewDetailDescriptor 엘리먼트를 사용하는 방법을 보여준다. ▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
<dxg:GridControl x:Name="gridControl" AutoGenerateColumns="AddNew"> <dxg:GridControl.View> <dxg:TableView ShowGroupPanel="False" AutoWidth="False" DetailHeaderContent="Employee" /> </dxg:GridControl.View> <dxg:GridControl.DetailDescriptor> <dxg:TabViewDetailDescriptor> <dxg:TabViewDetailDescriptor.DetailDescriptors> <dxg:DataControlDetailDescriptor ItemsSourcePath="OrderList"> <dxg:DataControlDetailDescriptor.DataControl> <dxg:GridControl AutoGenerateColumns="AddNew"> <dxg:GridControl.View> <dxg:TableView ShowGroupPanel="False" AutoWidth="False" DetailHeaderContent="Order" /> </dxg:GridControl.View> </dxg:GridControl> </dxg:DataControlDetailDescriptor.DataControl> </dxg:DataControlDetailDescriptor> <dxg:ContentDetailDescriptor ContentTemplate="{StaticResource NoteDataTemplateKey}" HeaderContent="Note"> </dxg:ContentDetailDescriptor> </dxg:TabViewDetailDescriptor.DetailDescriptors> </dxg:TabViewDetailDescriptor> </dxg:GridControl.DetailDescriptor> </dxg:GridControl> |
※ xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid
■ GridControl 엘리먼트의 DetailDescriptor 속성을 사용해 마스터-상세를 표시하는 방법을 보여준다. ▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
<Window.Resources> <DataTemplate x:Key="NoteDataTemplateKey"> <Border> <TextBlock TextWrapping="Wrap" Text="{Binding Path=Note}" /> </Border> </DataTemplate> </Window.Resources> ... <dxg:GridControl x:Name="gridControl" AutoGenerateColumns="AddNew"> <dxg:GridControl.View> <dxg:TableView ShowGroupPanel="False" AutoWidth="False" DetailHeaderContent="Employee" /> </dxg:GridControl.View> <dxg:GridControl.DetailDescriptor> <dxg:TabViewDetailDescriptor> <dxg:TabViewDetailDescriptor.DetailDescriptors> <dxg:DataControlDetailDescriptor ItemsSourcePath="OrderList"> <dxg:DataControlDetailDescriptor.DataControl> <dxg:GridControl AutoGenerateColumns="AddNew"> <dxg:GridControl.View> <dxg:TableView ShowGroupPanel="False" AutoWidth="False" DetailHeaderContent="Order" /> </dxg:GridControl.View> </dxg:GridControl> </dxg:DataControlDetailDescriptor.DataControl> </dxg:DataControlDetailDescriptor> <dxg:ContentDetailDescriptor ContentTemplate="{StaticResource NoteDataTemplateKey}" HeaderContent="Note"> </dxg:ContentDetailDescriptor> </dxg:TabViewDetailDescriptor.DetailDescriptors> </dxg:TabViewDetailDescriptor> </dxg:GridControl.DetailDescriptor> </dxg:GridControl> |
※ xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid ※ Order, Employee, 클래스는 WPF
더 읽기
■ GridControl 클래스의 CustomColumnDisplayText 이벤트를 사용해 커스텀 컬럼 디스플레이 텍스트를 처리하는 방법을 보여준다. ▶ 예제 코드 (XAML)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
<Grid xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"> <dxg:GridControl x:Name="gridControl" CustomColumnGroup="gridControl_CustomColumnGroup" CustomGroupDisplayText="gridControl_CustomGroupDisplayText"> <dxg:GridControl.Columns> <dxg:GridColumn FieldName="ProductName" /> <dxg:GridColumn FieldName="UnitsInStock" /> <dxg:GridColumn FieldName="UnitsOnOrder" /> <dxg:GridColumn FieldName="UnitPrice" SortMode="Custom"> <dxg:GridColumn.EditSettings> <dxe:SpinEditSettings DisplayFormat="c2" /> </dxg:GridColumn.EditSettings> </dxg:GridColumn> </dxg:GridControl.Columns> <dxg:GridControl.View> <dxg:TableView /> </dxg:GridControl.View> </dxg:GridControl> </Grid> |
▶ 예제 코드 (C#)
더 읽기