Quantcast
Viewing all 7205 articles
Browse latest View live

How to reset page numbering on a specific page

This example illustrates how to reset page numbering (in the document header) on a specific page. To achieve this goal, add a new Section to a document and set its PageNumbering.Start property (see SectionPageNumbering.Start) to 1. Note that page numbering is setup by creating a PAGE field in the document header. The entire document is generated programmatically.

Question Comments

Added By: Elmar Fuchs at: 9/9/2012 7:12:36 AM    

This sample doesn't work for me. I create an empty form, drag & drop the RichEdit control (v2012 vol 1.6) then copy these codes into the Form_Load event handling.

The result is I have 2 pages and in the header I have "Page 1" for page 1 and "Page 2" for page 2.
If I understood this sample correctly, the two pages has the same header "Page 1".

Have I done something wrong?

Thanks!

Added By: Oleg (DevExpress Support) at: 1/26/2016 6:29:25 AM    

Hello Elmar,
To process your recent post more efficiently, I created a separate ticket on your behalf: T338589: How to correctly reset page numbering in the RichEditControl document. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.


Report Storage for the End-User Report Designer (WPF beta)

The following example demonstrates how to implement a report storage to persist report definitions in a database or in any other custom location. This may be useful when providing end-users with the capability to create and customize reports using XtraReports End-User Designer if it is necessary to have a common target for saving and sharing all reports. At present, the aforementioned functionality is accomplished through the DevExpress.Xpf.Reports.UserDesigner.IReportFileStorage interface. The interface provides the following methods:
       • ShowSaveAsDialog
       • ShowOpenDialog
       • Load
       • Save
       • GetErrorMessage
As we see, the interface methods are quite straightforward: the first two methods are intended to show a dialog to an end-user where he can select a report among the predefined reports, or otherwise, save it; when he does that, the Save or Load methods are invoked with the unique name of the selected report. That's where you should implement your custom save logic. If you're unfamiliar with this procedure, please refer to the original E2704 example, which provides additional information in this regard (the example illustrates the same technique but for WinForms EUD)
__________________________________________________________________________________________________________________________________________

[v15.2 History changes]
The IReportFileStorage interface has been changed to IReportStorage.
This new interface provides the following methods:

• bool CanCreateNew();

Indicates where or not it's possible to create a new tab with a blank report in the designer.
• bool CanOpen();

Indicates where or not the "Open" BarItem is enabled.
• XtraReport CreateNew();

Provides the capability to customize a new report template.
 • XtraReport CreateNewSubreport();

Provides the capability to customize a new subreport report template (i.e., a new report opened by double-clicking a given XRSubreport control)
• string GetErrorMessage(Exception exception);

Provides the capability to display an error message for any encountered exception (a general one or the exception message if you expect that the user can understand and react based on this information)

• string Open(IReportDesignerUI designer);

This method expects a unique ID of the report selected by an end-user via your own UI dialog.
• XtraReport Load(string reportID, IReportSerializer designerReportSerializer);

This method passes the report ID that has been selected in the previous step and expects the actual report instance to be loaded and returned. You may or may not use the IReportSerializer  facilities to save or load a given report from a stream.

 • string Save(string reportID, IReportProvider reportProvider, bool saveAs, string reportTitle, IReportDesignerUI designer);

This method is intended to save the currently edited reports. 
The methods parameters are:
reportID is the unique ID of the edited report (null if it's a new report with no ID specified)
reportProvider allows you to get the actual report instance being edited and optionally rename it (a new name will be updated in the designer as well)
saveAs indicates which particular BarItem has been pressed ("Save" or "Save As")
reportTitle represents the actual report title (XtraReport.DisplayName)
designer is the actual report designer instance (the DevExpress.Xpf.Reports.UserDesigner.ReportDesigner class). Again, it's up to you whether to use it or not
__________________________________________________________________________________________________________________________________________

NOTE:
The WPF Report EUD is still in the beta stage (v.15.1); thus, there can be some limitations which are impossible to overcome at this moment (for example, there is no way to fill the SubReport's ReportSource drop-down window with the list of available reports). Moreover, some detail implementation may be changed on its official release. If you're experiencing any issues with running this sample or have additional questions, please contact our Support Team directly for further assistance.

How to pass a hidden dashboard parameter to a custom SQL query in the Web Viewer

The following example shows how to filter a custom SQL query by changing a parameter value in the ASPxDashboardViewer.CustomParameters event handler.

In this example, the custIDQueryParameter query parameter is included in a WHERE clause of a custom SQL query. The custIDQueryParameter parameter is also bound to the hidden custIDDashboardParameter dashboard parameter. The value of this parameter is changed at runtime by handling the ASPxDashboardViewer.CustomParameters event which is raised before the ASPxDashboardViewer sends a query to a database.

ASPxCardView - How to use the GetSelectedFieldValues method to obtain values of several columns at once

How to calculate multiple Custom Totals with SummaryType set to Custom

The following example demonstrates how to calculate and display multiple Custom Totals for a field.


In this example, two Custom Totals are implemented for the Category Name field. The first one displays a median calculated against summary values, while the second one displays the first and third quartiles.


To accomplish this task, we create two PivotGridCustomTotal objects and set their summary type to PivotSummaryType.Custom. We also assign the Custom Totals' names to PivotGridCustomTotalBase.Tag properties to be able to distinguish between the Custom Totals when we calculate their values. Finally, we add the created objects to the Category Name field's PivotGridField.CustomTotals collection and enable the Custom Totals to be displayed for this field by setting the PivotGridFieldBase.TotalsVisibility property to PivotTotalsVisibility.CustomTotals.


Custom Total values are actually calculated in the ASPxPivotGrid.CustomCellValue event. First, the event handler prepares a list of summary values against which a Custom Total will be calculated. For this purpose, it creates a summary datasource and copies the summary values to an array. After that, the array is sorted and passed to an appropriate method that calculates a median or quartile value against the provided array. Finally, the resulting value is assigned to the event parameter's PivotCellValueEventArgs.Value property.

How to provide custom editors for report parameters in WPF

This example demonstrates how you can provide custom editors for report parameters of arbitrary types. In particular, it shows how to utilize a custom ComboBoxEdit as an editor for a multi-value report parameter.

 To provide the described functionality, implement a custom parameter template selector and assign it to the PatameterTemplateSelector property of the DocumentPreviewControl's ParametersPanel. In this example, the custom parameters template selector extends the base ParameterTemplateSelector class with the capability to provide a custom editor template for each parameter whose MultiValue property is set to true. The custom editor template is declared in XAML.

How to filter a LookUpEdit in one column based on the value of another column

This example illustrates how to filter LookUpEdit item source values in one column based on the value of another column. This functionality can be implemented only when a filtered LookUpEdit is introduced using a cell template. In this case, every cell has an independent LookUpEdit editor, and we can manipulate its item source. The item source is filtered in the TableView.ShownEditor event handler. This event is raised when a cell gets focus, and its editor becomes active, so it is the best place to filter the item source.

Question Comments

Added By: David Stewart DK at: 1/2/2013 2:11:18 PM    

Notice that in the code below, the Name of the LookUpEdit MUST be "PART_Editor". This particular bit of magic was not clear to me...

/David

Added By: ArunKallingal at: 12/26/2013 5:07:38 AM    

Actually i want this in mvvm concept

Added By: Thomas R Melinsky at: 5/2/2014 4:47:23 AM    

I have compiled this with 12.2.8 and 13.2.7, and it has odd behavior with both.  Sometimes when viewing the cities list, there will only be one item in the list, the chosen city.  Other times when viewing the same city list (or another list item that has the same country selected), it will display all of the city choices.  Is it possible to fix the example as I was planning on using it as a reference?

Added By: Elliot (DevExpress Support) at: 5/2/2014 5:14:23 AM    

As an immediate solution, you can use the approach described in the E2163 code example to avoid this problem. Does it work for you?

Added By: John Genske at: 1/27/2016 6:04:56 AM    

We were looking for this answer forever, Two thumbs up!!

Added By: Andrey Marten (DevExpress Support) at: 1/27/2016 10:43:11 AM    
Hello John,

I'm happy to hear that the approach described in this example is suitable in your scenario. Please do not hesitate to contact us if you have other questions. We will be happy to assist you. 


Thanks,
Andrey

How to filter an SQL query at runtime in the WinForms Viewer


How to filter an SQL query at runtime in the Web Viewer

TokenEdit - How to implement reordering tokens via Drag&Drop

This example demonstrates how to implement the Drag and Drop functionality for reordering tokens.
Question Comments

Added By: Elena (DevExpress Support) at: 1/28/2016 1:21:16 AM    

Also, review the improvement of this example created by our customer.

ASPxCardView - How to display detail data within a popup window

ASPxCardView - How to display master-detail tables in two grids on separate tabs of a PageControl

How to use OData (WCF Data Services) to provide data for a report

At the moment, XtraReports cannot connect to an OData data source directly. 

Our reporting tools, however, are data source agnostic and support data sources of different types including .NET data providers, lists (implementing the System.Collections.IList, System.ComponentModel.ITypedList, or System.ComponentModel.IBindingList interface), and XML data sources. To learn more, refer to Data Binding Approaches.

So, to provide report data through the OData service, get IList data from the OData Service and then pass it to a report. Here are implementation details.

1. Add the OData Service Reference to your project. Now, the OData service context is registered in the application. See the Calling an OData Service From a .NET Client (C#) article for details.
2. Create a data model from the OData Service context. This data model will retrieve data from the OData service and return IList data.

Please note that OData defines query options that can be used to filter, sort, page data, and so forth. For more details, see the LINQ Considerations (WCF Data Services) topic on MSDN.

 

3. Bind a report to this data model through the ObjectDataSource component. Please note that it is necessary to retrieve actual data from a custom object data source. Please refer to Retrieve the Actual Data.

Using the Web Service as an XtraReport.DataSource

How to create a simple scheduling application that uses custom appointment fields and a custom editing form

Custom fields for appointments provide a way to associate arbitrary information with an appointment. This example represents a simple application that enables you to display, edit and save data contained in appointment custom fields. The application uses MS Access database as the data source.
Custom field mappings are established at design time using Mapping Wizards.
The InitNewAppointment event is handled to specify initial values for custom fields. The AppointmentInserting and AppointmentChanging events are handled to log changes or to prevent certain appointments from being created or changed.
To work with custom fields, a new appointment form is implemented. It descends form the DevExpress.XtraScheduler.UI.AppointmentForm, includes additional controls required to represent custom fields. To load and save custom fields a custom form controller is implemented. It inherits from the DevExpress.XtraScheduler.UI.AppointmentFormController and overrides several methods to provide the required functionality.

See also:
Custom form, custom fields and custom actions on reminder alert

Question Comments

Added By: Dean J. at: 9/19/2013 7:55:58 PM    

Since you recently updated this article, I was hoping the download example project was updated, but not so...it's from way back in VS 2005. Will you please fix the example project? After upgrading it to VS 2012 it still won't compile without fixing a couple of errors. And then when you run it, not happens...it appears it crashes in debug mode.

Also, is it normal to have to run the DX upgrader multiple times to get something this old up to the latest version (13.1 in my case) ?

Added By: Brian (DevExpress) at: 9/20/2013 12:49:51 AM    

I've checked if there is a problem with this example. I've successfuly download the C# version for v2013 vol 1.4 for VS 2010 (my ExampleRunner is set to VS 2010). The only problem is that my machine is 64-bit, so I had to specify x86 as the active solution platform in the Configuration manager in VS Designer. Then the application run as expected.

Added By: Dean J. at: 9/20/2013 9:05:44 AM    

I did not use the "runner". I used the link above that called "Example". If you open that project in VS 2012 (probably 2010 too), it will not run in debug mode.


How to save and restore layouts of floating documents residing within DocumentsHost

When you set the BaseView.FloatingDocumentContainer property to DocumentsHost, floating documents are hosted within a container to which other documents can be docked. Thus, this floating container contains its own DocumentManager. As a result, if you wish to save layouts of floating documents residing within such a floating container, you need to access their own DocumentManagers. You can do this in the BaseView.RegisterDocumentsHostWindow event handler. Finally, obtain a corresponding View via the DocumentManager.View property, and use its BaseView.SaveLayoutToXml and BaseView.RestoreLayoutFromXml or BaseView.SaveLayoutToStream and BaseView.RestoreLayoutFromStream methods. 

This example illustrates how to collect all the Views associated with floating containers, and save and restore their layouts. In short, we create a list of Views where we add a new View in the BaseView.RegisterDocumentsHostWindow event handler. We also delete a View after its floating container is destroyed in the BaseView.UnregisterDocumentsHostWindow event handler. 

Question Comments

Added By: Matthias Weidmann at: 1/29/2016 1:02:07 AM    

Hello and thanks for the example.

I have noticed that closed floating windows won't be opened during restore.
Do I have to disable the OnUnregisterDocumentsHostWindow event and recreate the closed floating windows within the OnRestoreLayout function? Or ist there an easier way of restoring closed floating windows?

Best regards,
Matthias

Added By: Svetlana (DevExpress Support) at: 1/29/2016 12:13:14 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T340260: A closed host window is not restored. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

ASPxCardView - How to specify the CommandButtons’ and Custom CommandButtons’ properties based on any custom criteria

The example demonstrates how to specify the CommandButtons and Custom CommandButtons properties by handling the CommandButtonInitialize and CustomButtonInitialize events. The DataRows' VisibleIndex property and criteria set based on field values are used to determine the buttons' visibility.

How to preserve the XtraGrid View state

This example demonstrates how to preserve the XtraGrid's expansion, selection, focused row and its position related to the top, and restore this state later.
For more information, please refer to the How to preserve the XtraGrid View state Knowledge Base article.

See Also:
How to preserve the expanded state of TreeList nodes when refreshing data

Question Comments

Added By: James Shipley at: 4/10/2014 6:29:37 AM    

This worked great for my application where I needed to preserve grouping! thanks

Added By: Gilles Guerette at: 5/19/2014 9:00:19 AM    

This is just what i needed. I've been fiddling with this for some time and this solves my problem. Thank you!

Added By: Harpreet Saini at: 2/19/2015 11:34:30 AM    

I had a problem with this, specifically with the SaveVisibleIndex and LoadVisibleIndex methods.  I wrapped the call to set my XtraGrid's datasource property between calls to SaveViewInfo and LoadViewInfo.  

           Me.m_helper.SaveViewInfo()
           Me.grdDailyAttendanceView.BeginUpdate()
           Me.grdDailyAttendance.DataSource = assignmentsByDateDT
           Me.grdDailyAttendanceView.EndUpdate()
           Me.m_helper.LoadViewInfo()

When the datasource is changed from a datatable without any rows (empty) to a datatable with rows I got a Arithmetic Overload error.   Expanding the SaveVisibleIndex and LoadVisibleIndex methods out:

Public Sub SaveVisibleIndex()
       Dim fRHand As Integer = view.FocusedRowHandle
       Dim vIdx As Integer = view.GetVisibleIndex(fRHand)
       visibleRowIndex = vIdx - view.TopRowIndex
End Sub

Public Sub LoadVisibleIndex()
      view.MakeRowVisible(view.FocusedRowHandle, True)
       Dim fRHand As Integer = view.FocusedRowHandle
       Dim vIdx As Integer = view.GetVisibleIndex(fRHand)       
       Dim myIndex As Integer = vIdx - visibleRowIndex
       view.TopRowIndex = myIndex
End Sub

When the SaveVisibleIndex method is called when the grid's datasource is set to an empty datatable the FocusedRowHandle equals Integer.MinValue and the VisibleIndex is also Integer.MinValue.  Concequently, the visibleRowIndex variable is set to Integer.MinValue.  

When the LoadVisibleIndex method is called after the grid's datasource is set to a non-empty datatable, the FocusedRowHandle is equal to -1, and the value zero (0) is returned from the call to GetVisibleIndex when -1 is passed (in the expanded code above the variable vIdx = 0) .  So, when the top row index is calculated => Dim myIndex As Integer = vIdx - visibleRowIndex it results in an arithmetic overload exception (0 - integer.minvalue).  To avoid this, I inserted an if block in the LoadVisibleIndex method as follows:

Public Sub LoadVisibleIndex()
      view.MakeRowVisible(view.FocusedRowHandle, True)
       Dim fRHand As Integer = view.FocusedRowHandle
       Dim vIdx As Integer = view.GetVisibleIndex(fRHand)

       If visibleRowIndex = Integer.MinValue AndAlso vIdx <> Integer.MinValue Then
           visibleRowIndex = 0

       End If      

       Dim myIndex As Integer = vIdx - visibleRowIndex
       view.TopRowIndex = myIndex
End Sub

Can someone from DevExpress please tell me if this solution is an optimal solution or if a different solution is recommended?  
tyvm.

Added By: Gosha (DevExpress Support) at: 2/20/2015 2:24:24 AM    

Hello Harpreet,

To process your recent post more efficiently, I created a separate ticket on your behalf: T211306: How to preserve the XtraGrid View state. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to provide GridControl Master-Detail extension with MVVM capabilities

This example illustrates how to add MVVM capabilities to the Master-Detail functionality introduced by the MasterDetailHelper extension class. In this example we have created the MasterDetailMVVMHelper class that introduces the ExpandedMasterRowsSource attached property. This property is intended to be attached to GridControl and allows controlling details' expanded state via a collection in a view model.

Here is a sample XAML that illustrates how to attach this property to GridControl and make it bound to the ExpandedItems collection:

[XAML]
<dxg:GridControlmy:MasterDetailMVVMHelper.ExpandedMasterRowsSource="{Binding ExpandedItems}"Name="gridControl1"ItemsSource="{Binding Data}">

 
Now, by adding a couple of data objects to the ExpandedItems collection, you can expand corresponding rows in GridControl:

[C#]
ExpandedItems.Add(Data[1]);ExpandedItems.Add(Data[10]);
[VB.NET]
ExpandedItems.Add(Data(1)) ExpandedItems.Add(Data(10))

An important note: The collection being bound to the ExpandedMasterRowsSource must be an implementation of the INotifyCollectionChanged interface, otherwise this functionality will not operate as expected.

Question Comments

Added By: Ipek Guven at: 6/26/2012 11:52:42 PM    

This solution is not working with the latest native Master-Detail feature in Vol 12.1. Can you upgrade the solution or provide a new one for the latest release?
Thanks in advance.
Ipek

Added By: James J Sullivan Sullivan at: 8/13/2012 6:26:49 PM    

Ipek, you might want to reference the Grid.Extensions dll as well.
http://www.devexpress.com/Support/Center/p/Q383850.aspx

Added By: Neeraj Thakur at: 1/31/2016 10:27:09 PM    

Is there any same example  for winforms
thanks Neeraj

Added By: Ivan (DevExpress Support) at: 1/31/2016 11:31:48 PM    

Hello Neeraj,

I have extracted your question to a separate ticket - How to obtain expanded rows when the Master-Detail functionality is used - and passed it to our WinForms team. That ticket is in our processing queue, and we will update it once we have any news.

How to: Create a Custom Control Detail Item

The complete description is available in the How to: Create a Custom Control Detail Item help topic.
Question Comments

Added By: Leon Meijer 4 at: 2/1/2016 4:09:25 AM    With version 2015, please change ControlDetailItem to ControlViewItem. Otherwise it won't work runtime.
Viewing all 7205 articles
Browse latest View live


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