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

How to generate Ribbon pages, groups and items based on a view model collection

$
0
0

This example demonstrates how to generate pages, groups and items from a collection according to the MVVM pattern. To generate pages in the RibbonPageCategory, bind the PagesSource property to a collection. Use the PageTemplate property to specify a template for generated pages.

RibbonPage and RibbonPageGroup contain similar properties for generating groups and bar items:

- GroupsSource, GroupTemplate

- ItemLinksSource, ItemTemplate


Building Outlook Navigation Menu Using OfficeNavigationBar and NavBarControl with TreeView

$
0
0

In Outlook 2013, you may notice a special menu at the bottom for navigation between different views. You can build such a menu with DevExpress controls using OfficeNavigationBar and NavBarControl. OfficeNavigationBar takes all groups from NavBarControl and displays them in one line. To bind OfficeNavigationBar to NavBarControl, use the OfficeNavigationBar.NavigationClient property. Please note that to display OfficeNavigationBar, it's necessary to set NavBarControl.Compact to false.

OfficeNavigationBar supports Peek Forms (popups displayed when you hover over an item). 


To enable them, set ShowPeekFormOnItemHover to true and specify the PeekFormTemplate property.

Note that to display custom content in NavBarGroups, it's necessary to set NavBarGroup.DisplaySource to "Content". It also makes sense to disable built-in group scrolling so that TreeView can use its own scrolling mechanism. To accomplish this task, set GroupScrollMode to "None".

How to navigate between views in NavigationFrame

$
0
0

This example demonstrates how to navigate between views without executing code at the view model level. If you wish to control navigation from the view mode, please refer to: How to: Navigate between Views via FrameNavigationService.

In this example, the NavigationButton element is used to perform navigation. To specify the target view, use the NavigateTo property. If you wish to use the standard Button, set the dxwuin:Navigation.NavigateTo attached property:

[XAML]
<ButtonContent="Tools"dxwuin:Navigation.NavigateTo="ToolsView"/>

Please note that the approach with the NavigationButton and Navigation.NavigateTo properties works only if the button is located in the NavigationFrame's visual tree.  You can also use the NavigationFrame.Navigate method to initiate navigation from code-behind. To specify the start view, set the Source property.


In this example, each view contains the PageAdornerControl. This element consists of a header and a back button. As a rule, the header is used for navigation buttons and for displaying the view name. The back button is visible only when the ShowBackButton is true.

To cache views in order to improve performance, set the NavigationCacheMode to "Required".

How to use the LayoutUpgrade event to upgrade a layout from one version to another

$
0
0

Sometimes it may be necessary to change the layout in your application (e.g., add a panel into the DockLayoutManager, rearrange groups, or add columns into the GridControl). In this case, a previously saved layout may require manual patching during the layout restoration. For this purpose, you can use the DXSerializer.LayoutUpgrade event. This event is raised if a restored layout version is lower than the current one. To set a layout version, use the DXSerializer.LayoutVersion attached property. 

Question Comments

Added By: Anand Jayaprakash at: 7/15/2016 1:10:51 PM    Hi,

Thank you for the response. Is there a way to figure out the list of incompatibilities?


Regards,
AnandJ Added By: Alex Chuev (DevExpress Support) at: 7/15/2016 2:03:24 PM    

Anand,

I've posted your commend in the T403971 - DXGrid column chooser - columns are showing up as blank - after column rename thread. Let's continue our discussion there.

Thanks,

Alex

How to group NavBarControl items generated from a collection

$
0
0

In this example, it's demonstrated how to use the GroupDescription property to automatically group items generated from a collection. To accomplish this task, it's necessary to set GroupDescription to a property name by which items should be grouped.


Another solution to group items is to bind NavBarControl to a source that implements ICollectionView and specify GroupDescriptions:

[C#]
CollectionViewEmployees.GroupDescriptions.Add(newPropertyGroupDescription("Department"));

 

If you wish to specify ItemsSource for each group separately, use the approach demonstrated at How to: Generate NavBarControl Groups and Items from a Collection

How to preserve the Legend checkbox item state when the Series Template approach is used

$
0
0
NOTE. Starting with v17.1, you can optionally save legend checkbox state for the chart's Series collection on callbacks. To activate this feature, enable the WebChartControl.SaveStateOnCallbacks option. If you prefer to use the manual Legend state initialization approach, set the SaveStateOnCallbacks property to False.

WebChartControl does not cache information about auto-generated Series when the Series Template approach is used to initialize the chart layout. In this situation, it is required to handle the WebChartControl.BoundDataChanged event to restore the Legend item checkbox state. This example illustrates how to save the Legend state into a Session variable using the WebChartControl.LegendItemChecked event and then restore it on subsequent page requests.

See also:

How to preserve the Legend checkbox item state when the Series collection is initialized programmatically
How to preserve the Legend checkbox item state in an ASP.NET MVC application.

How to implement highlight the nearest point on the Swift plot diagram

$
0
0

This example illustrates how to display a cross hair cursor and highlight the nearest Series point marker. The Series point value is displayed near a highlighted marker.

How to use a stored procedure with parameters as a data source in a Web application

$
0
0

This approach is actual prior to version 14.1. Starting with version 14.1, use the approach illustrated in the How to bind a report to a stored procedure provided by the SQL Data Source in an ASP.NET Web Forms application example.


To allow passing a procedure parameter to an XtraReport descendant class (XtraReport1), it's updated with an argument which is used while populating the DataSet instance.
On the web page, a DropDownList control is placed, which is populated with the list of parameters.
In the example, the "CustOrdersOrders" stored procedure (Northwind database) with the "CustomerID" parameter is used, so the DropDownList contains every CustomerID from the Customers table.

Within the Page_Load event handler, the ReportViewer.Report property is updated using a newly created report instance.

Question Comments

Added By: Jay Johnson at: 6/14/2012 2:26:38 PM    

Is there any "How To" for this? It seems to contradict other examples which use _BeforePrint

Is part of this example missing?

Added By: Mark D Loaney at: 6/20/2012 3:59:08 AM    

I've been wasting days trying to get this working, it appears that when I pass the parameters in the system breaks. I have a procedure that has the following parameters:

 @OrganisationID INT = 0,
    @Key INT = 3,
    @WeekStarting DATE = NULL,
    @WeekEnding DATE = NULL,
    @DivisionID INT = 0,
    @WorkgroupID INT = 0,
    @EmployeeID INT = 281,
    @Factor FLOAT = 0.00000

of which I only really need Key, EmployeeID, Division and Workgroup

The 'New' in xtrareports is as follows (note if I comment out the parameters passed in it works with the detault values and returns data:

Public Sub New(ByVal mEmployeeID As Integer, ByVal mKey As Integer, ByVal Org As Integer, divsn As Integer, wrkgp As Integer)
        MyBase.New()

        'This call is required by the Designer.
        InitializeComponent()
        cpM_Reports_StaffTableAdapter1.Fill(Me.staff1.CPM_Reports_Staff, Convert.ToInt32(Org), Convert.ToInt32(mKey), Convert.ToDateTime(Now()), Convert.ToDateTime(Now()), Convert.ToInt32(divsn), Convert.ToInt32(wrkgp), Convert.ToInt32(mEmployeeID))

    End Sub

ie this works, but of course the parameters aren't there!

Public Sub New() 'ByVal mEmployeeID As Integer, ByVal mKey As Integer, ByVal Org As Integer, divsn As Integer, wrkgp As Integer)
        MyBase.New()

        'This call is required by the Designer.
        InitializeComponent()
        'cpM_Reports_StaffTableAdapter1.Fill(Me.staff1.CPM_Reports_Staff, Convert.ToInt32(Org), Convert.ToInt32(mKey), Convert.ToDateTime(Now()), Convert.ToDateTime(Now()), Convert.ToInt32(divsn), Convert.ToInt32(wrkgp), Convert.ToInt32(mEmployeeID))

    End Sub

The proper values are coming in to the system when I put in a breakpoint - seems that the initialise isn't firing??

The code on the webform is

  Dim Division As Integer = 0
            Dim Workgroup As Integer = 0
            Dim Key As Integer = lstFilter.SelectedIndex
            If IsNumeric(lstDivision.SelectedValue) Then Division = CInt(lstDivision.SelectedValue)
            If IsNumeric(lstWorkgroup.SelectedValue) Then Workgroup = lstWorkgroup.SelectedValue
            Dim report As New XStaffActivity(Helpers.EmployeeID, Key, Helpers.MyCompanyID, Division, Workgroup)
            rvStaffActivity.Report = report

Help please (PS I've copied the full xtrareports code below (cutting out the 60 off labels etc on there):

Imports System
Imports DevExpress.XtraReports.UI
Imports System.Drawing.Printing
Public Class XStaffActivity
    Inherits DevExpress.XtraReports.UI.XtraReport

#Region " Designer generated code "

    Public Sub New(ByVal mEmployeeID As Integer, ByVal mKey As Integer, ByVal Org As Integer, divsn As Integer, wrkgp As Integer)
        MyBase.New()

        'This call is required by the Designer.
        InitializeComponent()
        cpM_Reports_StaffTableAdapter1.Fill(Me.staff1.CPM_Reports_Staff, Convert.ToInt32(Org), Convert.ToInt32(mKey), _
                                            Convert.ToDateTime(Now()), Convert.ToDateTime(Now()), Convert.ToInt32(divsn), _
                                            Convert.ToInt32(wrkgp), Convert.ToInt32(mEmployeeID))

    End Sub

    'XtraReport overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub
    Private WithEvents staff1 As Staff
    Private WithEvents cpM_Reports_StaffTableAdapter1 As StaffTableAdapters.CPM_Reports_StaffTableAdapter
    Private WithEvents groupHeaderBand1 As DevExpress.XtraReports.UI.GroupHeaderBand
    Private WithEvents xrLabel2 As DevExpress.XtraReports.UI.XRLabel
    Private WithEvents groupHeaderBand2 As DevExpress.XtraReports.UI.GroupHeaderBand
    Private WithEvents xrLabel4 As DevExpress.XtraReports.UI.XRLabel
    Private WithEvents groupHeaderBand3 As DevExpress.XtraReports.UI.GroupHeaderBand Private WithEvents xrPageInfo1 As DevExpress.XtraReports.UI.XRPageInfo
    Private WithEvents xrPageInfo2 As DevExpress.XtraReports.UI.XRPageInfo
    Private WithEvents reportHeaderBand1 As DevExpress.XtraReports.UI.ReportHeaderBand
    Private WithEvents xrLabel23 As DevExpress.XtraReports.UI.XRLabel
    Private WithEvents groupFooterBand1 As DevExpress.XtraReports.UI.GroupFooterBand
    Private WithEvents groupFooterBand2 As DevExpress.XtraReports.UI.GroupFooterBand
    Private WithEvents xrLabel24 As DevExpress.XtraReports.UI.XRLabel
      Private WithEvents Title As DevExpress.XtraReports.UI.XRControlStyle
    Private WithEvents FieldCaption As DevExpress.XtraReports.UI.XRControlStyle
    Private WithEvents PageInfo As DevExpress.XtraReports.UI.XRControlStyle
    Private WithEvents DataField As DevExpress.XtraReports.UI.XRControlStyle
    Private WithEvents topMarginBand1 As DevExpress.XtraReports.UI.TopMarginBand
    Private WithEvents bottomMarginBand1 As DevExpress.XtraReports.UI.BottomMarginBand
    'Required by the Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Designer
    'It can be modified using the Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Dim resourceFileName As String = "XStaffActivity.resx"
        Dim xrSummary1 As DevExpress.XtraReports.UI.XRSummary = New DevExpress.XtraReports.UI.XRSummary()
Dim xrSummary33 As DevExpress.XtraReports.UI.XRSummary = New DevExpress.XtraReports.UI.XRSummary()
        Me.Detail = New DevExpress.XtraReports.UI.DetailBand()
        Me.xrLabel60 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrVEmployee = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel51 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel14 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel15 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel16 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel17 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel18 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel19 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel20 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel21 = New DevExpress.XtraReports.UI.XRLabel()
        Me.xrLabel22 = New DevExpress.XtraReports.UI.XRLabel()
        Me.staff1 = New Staff()
        Me.cpM_Reports_StaffTableAdapter1 = New StaffTableAdapters.CPM_Reports_StaffTableAdapter() Me.Title = New DevExpress.XtraReports.UI.XRControlStyle()
        Me.FieldCaption = New DevExpress.XtraReports.UI.XRControlStyle()
        Me.PageInfo = New DevExpress.XtraReports.UI.XRControlStyle()
        Me.DataField = New DevExpress.XtraReports.UI.XRControlStyle()
        Me.topMarginBand1 = New DevExpress.XtraReports.UI.TopMarginBand()
        Me.bottomMarginBand1 = New DevExpress.XtraReports.UI.BottomMarginBand()
        CType(Me.staff1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()
        '
        'Detail
        '
        Me.Detail.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.xrLabel60, Me.xrVEmployee, Me.xrLabel51, Me.xrLabel14, Me.xrLabel15, Me.xrLabel16, Me.xrLabel17, Me.xrLabel18, Me.xrLabel19, Me.xrLabel20, Me.xrLabel21, Me.xrLabel22})
        Me.Detail.HeightF = 17.0!
        Me.Detail.Name = "Detail"
        Me.Detail.Padding = New DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100.0!)
        Me.Detail.StyleName = "DataField"
        Me.Detail.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft
        '
             'Title
        '
        Me.Title.BackColor = System.Drawing.Color.Transparent
        Me.Title.BorderColor = System.Drawing.Color.Black
        Me.Title.Borders = DevExpress.XtraPrinting.BorderSide.None
        Me.Title.BorderWidth = 1
        Me.Title.Font = New System.Drawing.Font("Arial Narrow", 21.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Title.ForeColor = System.Drawing.Color.Black
        Me.Title.Name = "Title"
        '
        'FieldCaption
        '
        Me.FieldCaption.BackColor = System.Drawing.Color.Transparent
        Me.FieldCaption.BorderColor = System.Drawing.Color.Black
        Me.FieldCaption.Borders = DevExpress.XtraPrinting.BorderSide.None
        Me.FieldCaption.BorderWidth = 1
        Me.FieldCaption.Font = New System.Drawing.Font("Arial Narrow", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FieldCaption.ForeColor = System.Drawing.Color.Black
        Me.FieldCaption.Name = "FieldCaption"
        '
        'PageInfo
        '
        Me.PageInfo.BackColor = System.Drawing.Color.Transparent
        Me.PageInfo.BorderColor = System.Drawing.Color.Black
        Me.PageInfo.Borders = DevExpress.XtraPrinting.BorderSide.None
        Me.PageInfo.BorderWidth = 1
        Me.PageInfo.Font = New System.Drawing.Font("Arial", 8.0!)
        Me.PageInfo.ForeColor = System.Drawing.Color.Black
        Me.PageInfo.Name = "PageInfo"
        '
        'DataField
        '
        Me.DataField.BackColor = System.Drawing.Color.Transparent
        Me.DataField.BorderColor = System.Drawing.Color.Black
        Me.DataField.Borders = DevExpress.XtraPrinting.BorderSide.None
        Me.DataField.BorderWidth = 1
        Me.DataField.Font = New System.Drawing.Font("Arial", 9.0!)
        Me.DataField.ForeColor = System.Drawing.Color.Black
        Me.DataField.Name = "DataField"
        Me.DataField.Padding = New DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100.0!)
        '
        'topMarginBand1
        '
        Me.topMarginBand1.HeightF = 31.0!
        Me.topMarginBand1.Name = "topMarginBand1"
        '
        'bottomMarginBand1
        '
        Me.bottomMarginBand1.HeightF = 25.0!
        Me.bottomMarginBand1.Name = "bottomMarginBand1"
        '
        'XStaffActivity
        '
        Me.Bands.AddRange(New DevExpress.XtraReports.UI.Band() {Me.Detail, Me.groupHeaderBand1, Me.groupHeaderBand2, Me.groupHeaderBand3, Me.pageFooterBand1, Me.reportHeaderBand1, Me.groupFooterBand2, Me.groupFooterBand3, Me.reportFooterBand1, Me.topMarginBand1, Me.bottomMarginBand1})
        Me.DataAdapter = Me.cpM_Reports_StaffTableAdapter1
        Me.DataMember = "CPM_Reports_Staff"
        Me.DataSource = Me.staff1
        Me.Landscape = True
        Me.Margins = New System.Drawing.Printing.Margins(83, 55, 31, 25)
        Me.PageHeight = 850
        Me.PageWidth = 1100
        Me.StyleSheet.AddRange(New DevExpress.XtraReports.UI.XRControlStyle() {Me.Title, Me.FieldCaption, Me.PageInfo, Me.DataField})
        Me.Version = "12.1"
        CType(Me.staff1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me, System.ComponentModel.ISupportInitialize).EndInit()

    End Sub
    Friend WithEvents Detail As DevExpress.XtraReports.UI.DetailBand

#End Region

End Class

Added By: Mark D Loaney at: 6/21/2012 2:54:27 AM    

Never mind, problem solved, I wasn't passing the parameters in on everypost back - had the code in a 'on Not Page.IsPostBack Then ...

took it out of that and beautiful!!

Added By: Thue Møller Jensen at: 12/7/2012 5:39:38 AM    

Thansk a lot Mark to Mark for posting this last comment. After wasting a couple of days on this problem, i found this page with the solution.

Added By: Henry F. Wilson at: 5/7/2014 11:08:50 AM    

Truly grateful. I have spent days finding solution to this problem and this post solves. Thanks guys.


How to preserve the Legend checkbox item state when the Series items are created manually

$
0
0

NOTE. Starting with v17.1, you can optionally save legend checkbox state for the chart's Series collection on callbacks. To activate this feature, enable the WebChartcontrol.SaveStateOnCallbacks option. If you prefer to use the manual Legend state initialization approach, set the SaveStateOnCallbacks property to False.

WebChartControl does not cache information about Series items and data source initialized at runtime. As a result, the Legend item checkbox state cannot be applied correctly. This example illustrates how to save the Legend state into a Session variable and restore it using the Page_Load event handler. The WebChartControl.LegendItemChecked event is used to obtain the current Legend panel state. Note that it is also required to disable the internal viewstate management using the WebChartControl.EnableViewState and WebChartControl.SaveStateOnCallbacks properties.

See also:

How to preserve the Legend checkbox item state when the Series Template approach is used to generate the Series collection;
How to preserve the Legend checkbox item state in an ASP.NET MVC application.

How to implement Appointment deleting confirmation using the popup menu option

$
0
0

This example illustrates the capability to substitute a default Delete menu item with a custom one, to display a confirmation dialog to an end-user.
The dialog is displayed within the custom DXMenuItem.Click event handler assigned to the corresponding menu item.

How to obtain an appointment that meets the specified criteria

$
0
0

This example illustrates the approach of searching a particular appointment using the AppointmentBaseCollection.Find(Predicate<T> match) method.
This allows quickly finding an object which meets the specified criteria.

Two-way model binding with single and multi-select editors or FormLayout

$
0
0

This example illustrates two-way Model Binding for different editor types. Standalone editors are located in the Editors.cshtml view. In addition, we have the FormLayout extension in the FormLayout.cshtml view. We use the simplest possible implementation for simplicity sake. For instance, in the case of standalone editors, we use Strongly-Typed Editor Types. Since ComboBox and TokenBox list editors fully support Model Binding, we also use them in this example. Other list editors do not fully support Model Binding and you need to use the approach illustrated in the E4125 - How to use the CheckBoxList and RadioButtonList editors to edit Model fields code example if you wish to work with them.

See Also:
KA18701 - MVC Data Editors - Model Binding and Editing 
T185980 - UploadControl with Model Binding Support - Registration Form

Creating a layout with SchedulerControl, DateNavigator and ResourcesCheckedListBoxControl

Override default colors from an existing Color Scheme and support system themes

$
0
0

This example illustrates how to override the default scheme colors for Windows 10 XAML controls and support system themes (Light, Default). With the current implementation, the RibbonControl header background is overridden in the Generic and Win8 schemes and has different values in these schemes for the Default and Light system themes.

 

Starting with v17.1, colors can be defined in code by overriding specific values in related ThemeManager dictionaries.

 

Note that the Dark system theme is determined as Default, so our theme manager uses the same colors for these themes in the Generic color scheme.


If you wish to do this in an older version, refer to the How to override default colors from an existing Color Scheme in Windows 10 XAML controls and support system themes (Light, Default) [Deprecated] example for a solution.

How to use WorkspaceManager for capturing, applying, saving and loading workspaces

$
0
0

This example demonstrates how to use standalone Workspace Manager API for capturing, applying, saving and loading workspaces and shows different Transition Types in action. 
You can find the general information about the WorkspaceManager in our documentation: Workspace Manager

Note that the Workspace Manager provides a bar menu, represented by the BarWorkspaceMenuItem class to assist both you and your end-users in creating, saving and loading workspaces. This item can be added to the required Bar or RibbonControl.


How to implement FilterControlCellEditorInitialize and FilterControlCellEditorCreate

MVC Splitter - Saving the client layout of the control after every modification by a user

$
0
0

This example demonstrates how to preserve the MVC Splitter layout when an end-user expands, collapses or resizes its panes. 

The Splitter extension is placed inside the CallbackPanel extension. In order to save its layout after a modification, you are required to handle corresponding client-side events and pass layout data to the server. This data is retrieved by using the ASPxClientSplitter.GetLayoutData method and passed as a parameter via the MVCxClientCallbackPanel.PerformCallback method to the server side to the corresponding Controller Action method. Then the client layout data is applied to Splitter in the SplitterSettings.ClientLayout  event handler.

server event.

See Also:
E3960: How to save ASPxSplitter's client-side layout after every modification of the control by an end-user

Report Server - How to get available reports and show them in MVC Document Viewer

$
0
0

It is a very basic ASP.NET MVC application that logs into the Report Server using Windows Authentication and displays a list of available reports. The ASPxDocumentViewer is used to display the selected report.

MonthCellControl - a custom style example

How to create a PropertyGrid toolbar that allows users to sort and categorize properties

$
0
0

In the example a bar with two buttons is created above a PropertyGridControl. The buttons are used to sort properties alphabetically and group properties by categories, respectively.
 To change the order of properties, the PropertyGridControl's OptionsView.ShowRootCategories property is used.

Viewing all 7205 articles
Browse latest View live


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