Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all 7205 articles
Browse latest View live

How to Edit an Entire Row and Post Changes to a Database

$
0
0

The GridControl supports the Edit Entire Row mode.

In default mode, changes made via in-place editors are immediately posted to your data source. Unlike default mode, Edit Entire Row requires users to press the Update button to explicitly post changes to your data source.

To activate Edit Entire Row mode, use the TableView.ShowUpdateRowButtons / TreeListView.ShowUpdateRowButtons property.

When you change cell values within a row, the GridControl “freezes” the UI. You cannot navigate away from the edited row until you record or cancel changes. To post changes made, click the Update button. If you click the Cancel button, changes will be discarded.

The GridControl in this example is bound to Entity Framework:

[C#]
publicMainWindow(){InitializeComponent();varcontext=newIssuesContext();grid.ItemsSource=context.Issues.ToArray();}publicclassIssuesContext:DbContext{// ... }

When you make changes to grid values, changes are made only to in-memory replicas, not to the actual data in the database. To save changes and intercept possible database errors, handle the GridViewBase.ValidateRow event and explicitly call SaveChanges on the DataContext:

[XML]
<dxg:TableViewShowUpdateRowButtons="OnCellEditorOpen"ValidateRow="TableView_ValidateRow"/>
[C#]
voidTableView_ValidateRow(objectsender,GridRowValidationEventArgse){varissue=(Issue)e.Row;using(varcontext=newIssuesContext()){varresult=context.Issues.SingleOrDefault(b=>b.Id==issue.Id);if(result!=null){result.Subject=issue.Subject;result.Priority=issue.Priority;result.Votes=issue.Votes;result.Priority=issue.Priority;context.SaveChanges();}}}

If an error occurs, the GridControl will allow you to correct values or click the Cancel button to return the previous value.


How to show a SuperToolTip for XtraForm's buttons

$
0
0

By default, XtraForm being a standard Form descendant shows standard tooltips. To show DevExpress SuperToolTips, implement the IToolTipControlClient interface for a form and create a custom FormPainter to override its WMNCHitTest and DoWndProc methods.

Files to look at:

XtraFormEx.cs (VB: XtraFormEx.vb)

How to Create a Report Bound to JsonDataSource

$
0
0

This example demonstrates how to use the JsonDataSource component to bind reports to JSON-formatted data. Refer to the JSON Data Source documentation section for more instructions.

Note:The JsonDataSource component uses the open-source Newtonsoft.Json library to provide JSON data at runtime. Install the Newtonsoft.Json package if your application does not have a reference to this library.

DialogService - How to close an opened dialog and specify the dialog result

$
0
0

This example demonstrates how to work with the currently opened dialog directly from its view model. The CurrentDialogService component is a handful tool in this case, which allows to close the dialog with one of the available results from within a command inside the view model.

How to Manage Tracked Changes in the Document

$
0
0

The following code sample project shows how to use Word Processing Document API to accept and reject revisions. Enable change tracking, specify revision's display options and export the result to the PDF format.

Files to look at:

Program.cs (VB: Program.vb)

How to Manage Tracked Changes

$
0
0

The following code sample project how to use the RichEditControl to view, accept and reject revisions in the document. Specify display options for revisions and reviewers whose revisions should be displayed.

image

Files to look at:

Form1.cs (VB: Form1.vb)

How to Manage Tracked Changes in DXRichEdit

$
0
0

The following code sample project shows how to view, accept and reject revision in RichEditControl for WPF. Specify display options for revisions and reviewers whose changes should be displayed.

image

How to repeat the Detail report band multiple times (a data-bound report)

$
0
0

If your report's data source is empty or not defined, you can specify how many times the Detail band content is printed through the XtraReport.PrintOptions.DetailCountOnEmptyDataSource property.

If a report is data bound, you can limit the number of times the Detail band is printed by using the DetailCount property.

Please note that the DetailCount property is designed to specify the maximum number (i.e., the limit) of times the Detail band is printed. In other words, if a data source contains one record, we cannot print it more than one time by using the DetailCount property.
We need to use the solution illustrated by this example. It demonstrates how to repeat a data source record depending on a value taken from another field. To achieve this, add an unbound DetailReportBand and control the number of copies using its ReportPrintOptions.DetailCountOnEmptyDataSource property.

See also:
How to print DetailBand multiple times regardless of the number of records

Files to look at:

Form1.cs (VB: Form1.vb)
Program.cs (VB: Program.vb)
XtraReport1.cs (VB: XtraReport1.vb)

How To Access and Modify Document's Custom Properties

$
0
0

The code sample below shows how to use the PdfDocument.CustomProperties property to access the collection of document's custom properties. You can add and delete custom properties or change associated names or values.

How to print DetailBand multiple times regardless of the number of records

$
0
0

Sometimes, it is necessary to print a detail section a particular number of times even if the underlying DataSource contains a less number of records. The current version of XtraReports does not allow one to print this section more times than the number of records.

As a solution for this task, you can clear the report's DataSource and DataMember properties, set the DetailPrintCountOnEmptyDataSource property to the necessary number, and then populate the detail section data manually using the DetailBand's BeforePrint event.

This example demonstrates this approach in action.

See also:
How to repeat the Detail report band multiple times (a data-bound report)

Files to look at:

Data.cs (VB: Data.vb)
Form1.cs (VB: Form1.vb)
Program.cs (VB: Program.vb)
XtraReport1.cs (VB: XtraReport1.vb)

How to use Report and Dashboard Server's export API from the ASP.NET Core MVC application

$
0
0

This example demonstrates how to use the Report and Dashboard Server's export API.

Run the Example

• Open the command line prompt and navigate to the example's root folder.

• Run the command below to trust the https certificate for ASP.NET Core development:
dotnet dev-certs https --trust

• Type dotnet run to build and run the example application.

After the application is built, open your browser and go to http://localhost:5000/ or https://localhost:5001/ to see the result.

How to enable the best fit for XRCrossTab columns at runtime

$
0
0

This example demonstrates how to enable the best fit for XRCrossTab columns at runtime. To access the cell in the XRCrossTab control, you need to use its name that you can determine by clicking this cell in Visual Studio's Report Designer. Then, use the cell's ColumnAutoWidthMode property to enable the best fit for the column.

Files to look at:

Form1.cs (VB: Form1.vb)

How to use the XRCrossTab control's expressions to conditionally adjust its appearance in Print Preview

$
0
0

This example demonstrates how to change the appearance of XRPivotGrid cells, headers and value fields based on their values (or, captions).

This can be achieved by handling the special PrintCell, PrintHeader, and PrintFieldValue events.

Note that the report's VerticalContentSplitting is set to Exact, to fit XRPivotGrid columns precisely to a page's width.

Files to look at:

Form1.cs (VB: Form1.vb)
Form1.cs (VB: Form1.vb)
Program.cs (VB: Program.vb)
XtraReport1.cs (VB: XtraReport1.vb)
XtraReport1.cs (VB: XtraReport1.vb)

How to create custom total columns in XRCrossTab at runtime

$
0
0

This example demonstrates how to create an XRCrossTab control with custom total columns at runtime. You can implement calculated columns by using unbound empty columns. To accomplish this task, you need to add an unbound field to the Data area and then, after the cross tab's layout was generated, assign desired expressions to the Text property of the cells created for these empty fields.

Files to look at:

Form1.cs (VB: Form1.vb)

Spreadsheet API - Part 3

$
0
0

This example demonstrates how to use the Spreadsheet Document API to programmatically manage spreadsheet documents, without the need for Microsoft Excel to be installed.

The application includes the RichEditControl used to display and edit the code. The code modifies the spreadsheet document loaded in the Workbook instance. To see the results, open the document in Microsoft Excel by clicking the button.

You can modify the code and watch the result. If an error occurs during compilation or execution, the backcolor of the code window changes.

This sample introduces API properties and methods used to perform the following operations:

• Apply data validation to control the type of data or the values that users enter into a cell
• Remove rows and columns that meet the specified condition
• Custom XML Parts examples

For more information, review the Examples section in the documentation.

The Universal Subscription or an additional Office File API Subscription is required to use this example in production code. Please refer to the DevExpress Subscription page for pricing information.

See also:

Spreadsheet Document API - Part 1

Spreadsheet Document API - Part 2

Files to look at:

CustomXmlPartActions.cs (VB: CustomXmlPartActions.vb)
DataValidationActions.cs (VB: DataValidationActions.vb)
RowAndColumnActions.cs (VB: RowAndColumnActions.vb)

How to load and upload images from/to Azure Blob Storage

$
0
0

This example illustrates how to load SVG images from Azure Blob Storage and upload local images to it.

To get started, you need to install the Azure.Storage.Blobs NuGet package and follow the steps from the Quickstart: Azure Blob storage client library v12 for .NET Microsoft topic.

We fetch images asynchronously and add them to GridControl by using UnboundSource that allows you to dynamically add columns and rows.

Alt text

By extending a context menu of PictureEdit, we also illustrate how to upload the editor's current image to Azure Blob Storage.

alt text

To run this example, it is also necessary to specify your connection settings in the Main method:

alt text

How to use DevExpress Reporting Components in Blazor applications

$
0
0

This example demonstrates how to integrate the HTML5 Document Viewer and End-User Report Designer into a Blazor application.

The solution is based on the client-server model and includes the BlazorReporting.Client and BlazorReporting.Server parts.

Server Side

An ASP.NET Core application that processes requests from the Document Viewer and Report Designer and provides a report storage.

These are the main steps to configure the server side:

1. Install the DevExpress.AspNetCore.Reporting and Microsoft.AspNetCore.Mvc.NewtonsoftJson NuGet packages.
2. Create a controller with an action that creates the Report Designer model.
3. Implement a report storage.
4. Register reporting services and the report storage in the Startup class.

Files to look at:

ReportingController.cs
CustomReportStorageWebExtension.cs
ReportFactory.cs
Startup.cs
Client Side

Defines the UI for the Document Viewer and Report Designer and implements the logic to respond to UI updates.

These are the main steps to configure the client side:

1. Install the devexpress-reporting, @devexpress/analytics-core and devextreme npm packages.
2. Create the *.razor files for the Report Designer and Document Viewer. To render these components, use the dxReportViewer and dxReportDesigner bindings. For both components, invoke an initialization method in the OnAfterRender lifecycle event and release unused memory in the Dispose event.
3. Create the *.js file and implement the logic to initialize and dispose of components.
4. Import required CSS styles.
5. (Optionally) Add the webpack.config.js file and create a bundle with Webpack.

Files to look at:

package.json
Viewer.razor
Designer.razor
index.js
style.css
webpack.config.js
NavMenu.razor

WinForms SpreadsheetControl API

$
0
0

This example demonstrates how to use the SpreadsheetControl API to programmatically manage spreadsheet documents, without the need for Microsoft Excel to be installed.

In particular, this sample introduces API properties and methods used to perform the following operations:

- Manage worksheets (activate, create, delete, rename, copy, adjust worksheet view, etc.)

- Manipulate rows and columns (insert, delete, copy rows and columns, adjust row height and column width, etc.)

- Manipulate cells and cell ranges (set cell values, add hyperlinks to cells, copy and merge cells), create, edit and copy cell comments

- Create formulas (use various functions and cell references in formulas, use names in formulas, create shared and array formulas, etc.)

- Format cells (set cell font, colors, alignment, borders, number format, etc.)

- Export the workbook to PDF

- Print the workbook

See also:
WinForms SpreadsheetControl API - Part 2
WinForms SpreadsheetControl API - Part 3

Files to look at:

Form1.cs (VB: Form1.vb)
CellActions.cs (VB: CellActions.vb)
FormattingActions.cs (VB: FormattingActions.vb)
FormulaActions.cs (VB: FormulaActions.vb)
ImportExportActions.cs (VB: ImportExportActions.vb)
PrintingActions.cs (VB: PrintingActions.vb)
RowAndColumnActions.cs (VB: RowAndColumnActions.vb)
WorksheetActions.cs (VB: WorksheetActions.vb)

Spreadsheet Document API - Part 1

$
0
0

This example demonstrates how to use the Spreadsheet Document API to programmatically manage spreadsheet documents, without the need for Microsoft Excel to be installed.

In particular, this sample introduces API properties and methods used to perform the following operations:

- Manage worksheets (activate, create, delete, rename, move, copy, show/hide worksheets, adjust worksheet view, etc.)

- Manipulate rows and columns (insert, delete, copy, show/hide, group rows and columns, adjust row height and column width, etc.)

- Manipulate cells and cell ranges (set cell values, add hyperlinks to cells, name, copy and merge cells)

- Create formulas (use various functions and cell references in formulas, name formulas and use names in formulas, create shared and array formulas, etc.)

- Format cells (create, modify and apply styles, set cell font, colors, alignment, borders, number format, etc.)

- Import data from different sources

- Export the workbook to PDF

- Print the workbook

For more information, review the Examples section in the documentation.

The Universal Subscription or an additional Office File API Subscription is required to use this example in production code. Please refer to the DevExpress Subscription page for pricing information.

See also:
Spreadsheet Document API - Part 2
Spreadsheet Document API - Part 3

Files to look at:

CellActions.cs (VB: CellActions.vb)
DocumentPropertiesActions.cs (VB: DocumentPropertiesActions.vb)
ExportActions.cs (VB: ExportActions.vb)
FormattingActions.cs (VB: FormattingActions.vb)
FormulaActions.cs (VB: FormulaActions.vb)
ImportActions.cs (VB: ImportActions.vb)
PrintingActions.cs (VB: PrintingActions.vb)
RowAndColumnActions.cs (VB: RowAndColumnActions.vb)
WorksheetActions.cs (VB: WorksheetActions.vb)

WPF SpreadsheetControl API - Part 1

$
0
0

This example demonstrates how to use the SpreadsheetControl API to programmatically manage spreadsheet documents, without the need for Microsoft Excel to be installed.
Double-click the action name in the Navigation Bar to run the code that illustrates the API functionality. The results are shown in the SpreadsheetControl and saved to the SavedDocument.xlsx file in the Document subfolder of the working folder.

In particular, this sample introduces API properties and methods used to perform the following operations:

- Manage worksheets (activate, create, delete, rename, copy, adjust worksheet view, etc.)

- Manipulate rows and columns (insert, delete, copy rows and columns, adjust row height and column width, etc.)

- Manipulate cells and cell ranges (set cell values, add hyperlinks to cells, copy and merge cells), create, edit and copy cell comments

- Create formulas (use various functions and cell references in formulas, use names in formulas, create shared and array formulas, etc.)

- Format cells (set cell font, colors, alignment, borders, number format, etc.)

- Export the workbook to PDF

- Print the workbook

See also:
WPF SpreadsheetControl API - Part 2
WPF SpreadsheetControl API - Part 3

Files to look at:

MainWindow.xaml.cs (VB: MainWindow.xaml.vb)
CellActions.cs (VB: CellActions.vb)
FormattingActions.cs (VB: FormattingActions.vb)
FormulaActions.cs (VB: FormulaActions.vb)
ImportExportActions.cs (VB: ImportExportActions.vb)
PrintingActions.cs (VB: PrintingActions.vb)
RowAndColumnActions.cs (VB: RowAndColumnActions.vb)
WorksheetActions.cs (VB: WorksheetActions.vb)
Viewing all 7205 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>