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

How to print DevExpress ASP.NET controls via XtraReports

$
0
0

This example illustrates how to print and/or export DevExpress ASP.NET controls by embedding them into an XtraReport.

In this example an ASPxGridView and WebChartControl are added to a report by using DevExpress.XtraReports.UI.PrintableComponentContainer objects.

Question Comments

Added By: Dhaval.Shah at: 11/21/2013 12:58:11 AM    

Hi all,
When I try to open this solution with VS2010 (DevEx 13.1.7), it says project is incompatible with current version of Visual Studio.
Can you please help?
Thanks

Added By: Paul Astro at: 2/5/2015 2:46:59 PM    

When I try to run the Example via the Example Runner, VS2013 Pro opens on my desktop and i have any error message; "Incopatible" "This project is incompatible with the current version of Visual Studio".  I installed the latest Example Runner. ?

Added By: Dmitry Tok (DevExpress Support) at: 2/5/2015 11:35:59 PM    

Hello Paul,
I'm afraid that I'm not able to reproduce this behavior on my side using Visual Studio 2013 and the latest version of the Example Runner tool. Actually, the *.dxsample file can be opened using the WinRar archiver and in the archive, you'll find the contents of this Code Example. Please let me know if I can be of further assistance.
Thanks

Added By: satish kumar 35 at: 2/19/2015 9:41:29 PM    

while i am using this i got error at PrintableComponentContainer  how to resolve this

Added By: Andrew L (DevExpress Support) at: 2/19/2015 11:06:57 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T211194: Issue with the E4828 example. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.


How to preserve the XtraGrid View state

$
0
0

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.

Expression Editor - How to implement a custom New Line function

Why DevExpress ASP.NET containers re-create their child control hierarchy

$
0
0

This example demonstrates why DevExpress ASP.NET WebForms containers have to re-create their hierarchy on postbacks. The example contains two ASPxRoundPanels. The View property of both panels is changed on the first page loading. The value is saved in ViewState. On every next page postback, the value is applied to the corresponding property.
The second ASPxRoundPanel does not re-create its hierarchy after ViewState is applied (EnableHierarchyRecreation="false") and its layout gets broken after a postback.

See the Why DevExpress ASP.NET control containers re-create their child control hierarchy during the same page request article to learn more about this topic.

How to conditionally suppress summary footer cell painting by using formatting rules

$
0
0

The main idea is to adjust a FormattingRule for a label that represents a summary. Use the Formatting.Visible property to control item visibility and the FormattingRule.Condition property to provide an expression based on your condition. 

This example illustrates the latter approach. An aggregate function of the following format is used in the example:
"[Collection][Condition].Sum("Field")"
The Sum function summarizes all "Field" values that match the Condition.

 

For further information, see:
How to: Calculate an Aggregate Function.
Criteria Language Syntax

Conditional Formatting
How to: Conditionally Suppress Controls

How to get all images provided by the DevExpress Icon Library

How to implement CRUD operations with a DataSource

$
0
0

This example demonstrates how to implement CRUD operations with a DataSource that obtains data from a remote Rest service. The DataSource object does not implement CRUD operations out-of-the-box. We can do this using jQuery.ajax. It is also necessary to call the DataSource.load method to "inform" your widget that it is necessary to reload its content.

See also:
Connect to RESTful Service
How to implement the Rest service based on an ASP.NET WebAPI application
dxDataGrid - How to implement a custom store with CRUD operations

Question Comments

Added By: Leovin S at: 8/20/2013 3:38:42 AM    

Thank you for the code.But the problem is that it is related to data that is retrieved through the service.I tried getting my data retrieved from my json file but then it shows errors.
So ,if you could give me a stand alone project ,including the data base I would be able to understand very clearly.

Added By: pedro azpurua at: 2/18/2014 5:59:29 AM    

I M P R S S I V E after four months working with OData this sample is the Nirvana

Added By: Muhammad Syarif at: 6/10/2014 7:27:29 PM    

this tutorial very good.but when i try it and run i get message "No data display" in my emulator.why that happen??
please help me.thank you.

Added By: Muhammad Syarif at: 6/10/2014 9:50:16 PM    

hello devexpress.
i download this source code and run it, i change the destination of database to http://localhost:9839/DataService.svc/Categories
but i just get Loading in my emulator. what the wrong, please help me.thank you

Added By: Nikolai (DevExpress Support) at: 6/10/2014 11:16:47 PM    Hi,

Please test this example with How to implement the Rest service based on an ASP.NET WebAPI application.Added By: agit yıldız at: 2/20/2015 7:38:07 AM    

I use Visual Studio 2013. I downloaded Example and open the solution.
When I run project I can't see categories list.It is empty but  I can add new category

The second problem is
I can't open  dxview files in VS2013. When add new DevExtreme 14.2 application, it is normaly

can you help me ?

How to handle the Back button click

$
0
0

This example demonstrates how to handle the Back button click. The HtmlApplication.navigatingBack event allows us to accomplish this task. However, this event handler does not provide information about the current view and its view model. Sometimes it is necessary to perform some actions before navigating. To solve this problem, we declare an additional option in the context of our application - HtmlApplication.currentViewModel. This option will store the necessary information about the current view, namely the current view model. The HtmlApplication.viewShown event handler allows you to get a view model of the shown view. We can get this view model and set it to our new option. In this case, we can access the current view model using HtmlApplication.currentViewModel and perform necessary actions in the HtmlApplication.navigatingBack event handler. Moreover, we can cancel back navigation in this event handler using the cancel option of the event handler argument as shown below:

[JScript]
Application1.app.currentViewModel = null; Application1.app.viewShown.add(function(e){ Application1.app.currentViewModel = e.viewInfo.model;}); Application1.app.navigatingBack.add(function(e){if(Application1.app.currentViewModel.name == 'View1'){if(!confirm("Are you sure you want to leave View1 ?")){ e.cancel = true;return;}//Execute the required code} Application1.app.currentViewModel = null;});

This code demonstrates how to perform actions when a user clicks the Back button on View1.

Question Comments

Added By: Paul Haffner at: 2/20/2015 10:18:14 AM    

This works fine in the emulator, but when I run it on a real device running Windows Phone 8.1, the event is not triggered. Instead the app terminates immediately when the hardware back button is pressed. I am using dx 14.2.


PictureEdit - How to display external images by providing links for them

$
0
0

The current example illustrates how to customize the default PictureEdit editor so that it can accept a path to a graphic file as an EditValue and display a corresponding image.

Question Comments

Added By: zheng zhong at: 11/23/2012 1:30:57 AM    

that way ,the file will be readed and readed again。
every time when shows the picture。
if I loading the file from website ,so slowly.

Added By: zheng zhong at: 11/23/2012 1:53:31 AM    

and
if you modify GraphicsEditViewInfo like this

 class GraphicsEditViewInfo : PictureEditViewInfo
        {
            public GraphicsEditViewInfo(RepositoryItem item) : base(item) { }

            public static Hashtable Images = new Hashtable();

            public override object EditValue
            {
                get
                {
                    return base.EditValue;
                }
                set
                {
                    if (value != null && value.GetType() == typeof(System.String))
                    {
                        if (Images.ContainsKey(value))
                        {

                            try
                            {
                                base.EditValue = Images[value];
                            }
                            catch
                            {
                                base.EditValue = Item.ErrorImage;
                            }
                        }
                        else
                        {

                            try
                            {
                            using (WebClient w = new System.Net.WebClient())
                            {
                                var b = w.OpenRead(value.ToString());
                                var bitmap = new Bitmap(b);
                                Images.Add(value, bitmap);
                            }
                           
                                base.EditValue = Images[value];
                            }
                            catch
                            {
                                base.EditValue = Item.ErrorImage;
                            }
                        }
                    }

                    else
                        base.EditValue = value;
                }
            }

        }

Added By: Martin Schönholzer CH at: 2/16/2015 5:48:54 AM    

Hi. I tried to use this tip to display external images. But in my case the RepositoryItemGraphicsEdit class is not found. What assembly contains this class and in what namespace?

Added By: Alisher (DevExpress Support) at: 2/16/2015 6:25:49 AM    

Hi Martin,

We don't have a RepositoryItemGraphicsEdit class in our WinForms library. This example illustrates how to create it. Please download it to see the implementation. 
Let us know of your results.

Added By: Martin Schönholzer CH at: 2/21/2015 7:16:53 AM    

It worked, thanks Alisher. ;)

How to: Use WindowedDocumentUIService

$
0
0
This example demonstrates how to use the WindowedDocumentUIService.

Print Preview - How to implement a drop-down menu for sorting report data

$
0
0
This example demonstrates how to implement a drop-down menu that allows you to choose the sort order for a table column and then sort a table.
This approach implies that you initially assign a special value to the Tag property of the XRTableCell that represents a header cell.

To initiate sorting for a column, assign the "Sort_<FieldName>" string to Tag.
 
You can also implement a 'Clear All' label. To do so, assign the "Clear_Sort" string to the XRControl.Tag property.

Please note that with this approach, we do not recommend using the standard approach which implies using a band's SortFields collection.

See also:
How to: Sort a Report in the Preview
How to sort a report in preview

How to hide a side component's properties from the End-User Designer Properties window

$
0
0
You can customize the Properties window for the report's End-User Designer, so only required properties are displayed.
The How to: Hide Properties from End-Users in the Report Designer example illustrates how to implement this. The idea is to handle the static XtraReport.FilterComponentProperties event and hide (or remove) an unnecessary property from the entire control's properties collection.

Please note that this approach is applicable for a report, its bands and XRControls (XRControl class descendants).

If you want to hide properties for a non-XRControl descendant, for instance, for the report's data source, we recommend the following. 

In the XRDesignMdiController.DesignPanelLoaded event handler, substitute the default ITypeDescriptorFilterService object with your custom one. In this custom ITypeDescriptorFilterService class, override the FilterProperties method to remove unnecessary properties.

In this example, we are using the SqlDataSource component as a report's data source. For more information on it, see How to: Bind a Report to a Database.

See also:
Customize an End-User Report Designer 

How to customize the map pushpin's appearance and behavior using the MarkerTemplate and the Template properties

$
0
0
This example demonstrates how to customize the map pushpin's appearance and behavior.
For this, the Template and the MarkerTemplate properties are used.

How to use a custom marker template used by a bubble chart

$
0
0
This example demonstrates how to specify a custom marker template used by a bubble chart.
For this, assign a required marker template to the CustomMarkerTemplate property of a MapBubble object.
Note that the MarkerType property should be set to Custom.

How to specify a custom marker template to be used by automatically generated bubble chart items


How to create bar button items and add a separator between them

$
0
0

This example shows how to create bar button items (BarButtonItem objects) and add a link separator between them. The separator is created using the DevExpress.Wpf.Bars.BarItemLinkSeparator class.

How to create bar items and associate them with categories

$
0
0

This example shows how to create bar items and associate them with a custom Format category.

How to: use NotificationService

$
0
0
This example demonstrates how to use NotificationService to show notifications. NotificationService is used in the same manner as other services. When the UseWin8NotificationsIfAvailable option is enabled, it's necessary to use an appropriate ApplicationId. 
This id should be specified in the application shortcut located in the "%APPDATA%\Roaming\Microsoft\Windows\Start Menu\Programs" directory. This is a requirement of the technology. To create a shortcut with the required application id, you can use our DevExpress.Data.ShellHelper class as shown below:
[C#]
DevExpress.Data.ShellHelper.TryCreateShortcut("sample_notification_app","DXSampleNotificationSevice");

Then, assign sample_notification_app to the NotificationService.ApplicationId property:

[XAML]
<dxmvvm:Interaction.Behaviors>     <dxmvvm:NotificationServicex:Name="ServiceWithDefaultNotifications"ApplicationId="sample_notification_app".../></dxmvvm:Interaction.Behaviors>

An advantage of native Windows 8 notifications is that thy can be shown over WinRT applications



Question Comments

Added By: jun yang 5 at: 2/24/2015 10:53:05 AM    

Hi,
Will it work on Windows 7 with .NET 4.5.1 installed?

Jun

Added By: Ivan (DevExpress Support) at: 2/24/2015 11:41:52 AM    

Yes, it should work there. Moreover, I tested the NotificationService on Windows XP in the past, and it also worked properly.

How to display word-wrapped or clipped text

$
0
0

This is an example for the How to display word-wrapped or clipped text in the ASPxGridView Knowledge Base article. Please refer to the article for the explanation.

Question Comments

Added By: John Zhang at: 2/24/2015 12:01:26 PM    

Is this works for xaf listview?

John

Added By: Alessandro (DevExpress Support) at: 2/24/2015 12:21:57 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T212747: xaf listview - How to display word-wrapped or clipped text. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to customize a map pie appearance

$
0
0
This example demonstrates how to customize a map pie appearance.
Viewing all 7205 articles
Browse latest View live


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