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

How to implement BackstageButtonItem with ToggleButton behavior

$
0
0

This example demonstrates how to implement a BackstageButtonItem with ToggleButton behavior.

This functionality is implemented via a BackstageButtonItem descendant. The BackstageButtonItem acquires the selected state when being clicked. When the BackstageButtonItem is double-clicked, a command assigned to it is executed.


How to generate row and cell styles using conditional expressions in WPF DXGrid

$
0
0

This example illustrates how to add the DXGrid behavior when you can use some conditional expressions and apply your custom style for cells and rows.


OBSOLETE. Starting from version 14.1, DXGrid introduces the built-in conditional formatting feature. See the Conditional Formatting article and the E983 - How to implement conditional formatting for rows ticket for details.
Question Comments

Added By: Mark G Servidio at: 1/9/2013 6:26:06 PM    

Is there an example of this same functionality for Silverlight? We require an almost identical functionality for our users.

Added By: David Hsu 1 at: 10/14/2013 9:19:49 AM    

It was great to be able to customize appearance using expression. But I found the appearance didn't get updated when I check/uncheck "IsCompleted" field.

I added INotifyPropertyChanged to Task object. Also I switched to different row to make the data saved to underline data.

Added By: Andrey K (DevExpress Support) at: 10/13/2015 6:06:54 AM    Hi,

We accidentally discovered that your comments were out of scope of our Support Center for a long time. If these issues are still actual, please create corresponding tickets in our SC.

 

Thanks,

Andrey

How to delete all criteria corresponding to a particular field from CriteriaOperator

$
0
0

This example demonstrates how to implement a helper that removes all expressions referencing a certain property from the CriteriaOperator. For example, you may want to programmatically remove fragments like "[SavedPassword] = '***'" from filter expressions that persist on client computers, because you decided to remove the SavedPassword property from the model for security reasons.

Although this task can be accomplished using regular expressions, this approach is too complicated and is applicable only to CriteriaOperator expressions that follow a certain pattern. This example uses a different technique, which allows you to support expressions of any complexity with minimum effort.

The solution demonstrated in this example uses the concept described in this Knowledge Base article: Implementation of the base class for a CriteriaOperator expression patcher. The CriteriaPatcherBase class is used in this example as a base class for the CriteriaPatcherSkipProperties class.

To remove any reference to a specific property from the CriteriaOperator expression, override the CriteriaPatcherBase.VisitProperty method, and return null (Nothing in Visual Basic) if the property name matches the name of a property that should be removed.

[C#]
protectedoverrideCriteriaOperatorVisitProperty(OperandPropertytheOperand){if(PropertiesToremove.Contains(theOperand.PropertyName))returnnull;returntheOperand;}
[VB.NET]
ProtectedOverridesFunction VisitProperty(ByVal theOperand As OperandProperty) As CriteriaOperatorIf PropertiesToremove.Contains(theOperand.PropertyName) ThenReturnNothingEndIfReturn theOperandEndFunction

However, this is incomplete. The expression will contain invalid statements if you simply remove properties from it: "() = #2015-12-30# And StartsWith([City], 'q')". To delete invalid statements from the expression, override the VisitAggregate, VisitFunction, VisitGroup, VisitIn, VisitUnary, VisitBinary, and VisitBetween methods. The implementation of overridden methods is demonstrated in the CriteriaPatcherSkipProperties.cs and CriteriaPatcherSkipProperties.vb files.

See also:
Implementation of the base class for a CriteriaOperator expression patcher

How to create a custom converter to convert the CriteriaOperator to the System.String type

How to use the Messenger in a CRUD application

$
0
0

This example shows how to create a CRUD application based on the DevExpress MVVM Framework.
It uses the Entity Framework Code First technology to work with a database and the DevExpress POCO technology to create ViewModels.
The Messenger is used for implementing interaction between ViewModels.
Views are built with the DevExpress Scaffolding Wizards.

Question Comments

Added By: Christian Weber 4 at: 7/13/2015 11:30:51 PM    

I just downloaded the example. I get an exception (System.Data.Entity.Core.ProviderIncompatibleException) when I want to execute the program. The exception is thrown in EmployeeCollectionViewModel::Initialize(), Line 73 (EmployeeContext.Employees.Load();).

Version: 15.1.4.0 (Trial)

Added By: Ivan (DevExpress Support) at: 7/14/2015 3:38:05 AM    Hi Christian,

I have created a new ticket on your behalf regarding this issue - ProviderIncompatibleException occurs when running E5001. Let's continue our discussion there.

Added By: Sascha Kretz 1 at: 9/6/2016 6:54:01 AM    Hello,

is there an updated example for the Messenger usage in mvvm?
As E5001 does not work for me either.

Rgds,
Sascha Added By: Alexander Ch (DevExpress Support) at: 9/6/2016 11:27:14 AM    

Hi Sascha,

Let's discuss this issue in a separate thread: T423955 - The E5001 example does not work.

Thanks,

Alex

How to colorize Pushpin items based on data source data

$
0
0

A MapPushpin item is displayed by a simple image. By default, this image is loaded from the current Skin. The only way to change the pushpin color is to replace this image with a custom one using the Image property. This example demonstrates how to modify the color of the pushpin image using the ColorMatrix Class. For the sake of simplicity, we prepared a clear red custom pushpin. We update and assign it to a certain item from the IMapItemFactory.CreateMapItem Method.

How to handle keyboard focus

$
0
0

This example illustrates how to move keyboard focus between RichEditControl and adjacent controls when the TAB or SHIFT+TAB key combinations are pressed. This allows you to overcome the following limitation: Need the AcceptTab property.

The main idea is to set the KeyboardNavigation.TabNavigation property for a RichEditControl to Once to avoid visiting its child elements and process tab navigation keys manually. 

How to change the size of the scroll bar buttons in the GridView

$
0
0

This example demonstrates how to create a custom scroll bar and use it as a scroll bar in the GridControl.

See Also:How to create a GridView descendant class and register it for design-time use.

Question Comments

Added By: Kristof Verbruggen at: 9/7/2016 2:37:10 AM    I reproduced the example and it works fine for me, I have the scrollbars width doubled.
I have the customer grid in my VS toolbox and when I drag it to a form, the custom gridcontrol is created. (added the attribute "[ToolboxItem(true)]" to the custom gridcontrol class)

Unfortunately the custom gridview is not created and selected as the mainview of the control, the devexpress gridview is created and selected.

What do I need to do the automatically create and select my custom gridview as the mainview for my custom gridcontrol when I drag the custom gridcontrol on to a form ?

How to customize a cell in the exported Excel document

$
0
0

When exporting a Pivot Grid control to XLSX (or XLS) format, you can customize a cell appearance in the exported document using the PivotXlsxExportOptions.CustomizeCell (or PivotXlsExportOptions.CustomizeCell) event.

In this example, custom appearance settings (the azure background and italic font) are applied to the cells that correspond to the Pivot Grid's data area. The CustomizePivotCellEventArgs.ExportArea property is used to identify cell location in the exported Excel document. The cell format is set by the CustomizePivotCellEventArgs.Formatting property.


How to dynamically generate Table Of Contents by adding TOC field with different nesting levels

$
0
0

The main form of this example contains the following elements:
1. RichEditControl - to show the Table Of Content (TOC)
2. TextEdit - to enter a text for a TOC field header
3. SpinEdit - to specify a nesting level of a TOC field
4. MemoEdit - to enter the main content of a current TOC level

In this example, we also demonstrated how to change the predefined formatting of TOC fields.
Along with the source code of the example, you can also find a video illustrating how the sample works.

How to draw a logo on RibbonControl

$
0
0

This example demonstrates how to create a helper component that allows drawing a logo at the right side of the RibbonControl.


To use this helper in your project, drop it onto the form from the Visual Studio ToolBox (you need to rebuild the project first). Then, set the RibbonControl and Image properties. If you wish to provide more complex logic, for example, draw this logo on a specific Ribbon page, go to the RibbonLogoHelper.DrawRibbonLogo method and add the required condition there.

How to suppress the "Report has been changed. Do you want to save changes" message when closing a report in the End-User Report Designer

How to customize file names in DifferentFiles export mode when exporting to MS Excel

How to use the SvgImageSource extension to specify a vector image as BarButtonItem's glyph

$
0
0
The SvgImageSource extension allows you to specify a vector image as BarButtonItem's glyph . You can reference a resource in xaml as follows:
[XAML]
Glyph="{dx:SvgImageSourceUri=Images/Notebook.svg}"
where dxis the xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" namespace.

See also:
Binding Mechanism.
Question Comments

Added By: David Lemieux at: 9/8/2016 5:05:32 AM    Is this supposed to work when the extension is used from inside a DataTemplate, which in turn is within a ResourceDictionary in a file from another assembly? Will the uri be resolved relatively to the RD file location?Added By: Andrey Marten (DevExpress Support) at: 9/8/2016 7:07:24 AM    
Hello David,

I see that I missed a similar question in your thread (T424596). Please accept my apologies for that. I hope you wouldn't mind if I answer you there.
I've updated both your description and my answer in that thread. Take a moment to review it and let me know if you have other questions. 


Thanks,
Andrey

How to: Use the Integrated Mode of the Security System in Non-XAF Applications

How to check if a Point is inside a Polygon using the Ray Casting algorithm


How to implement a date range picker in ASPxGridView using a column's field name

$
0
0
This example demonstrates how to implement a date range picker in ASPxGridView using a column's field name.

How to: Add custom buttons before the DXWindow's default buttons

$
0
0

This example demonstrates how to add custom buttons before the DXWindow's default buttons by using the HeaderItems property.

 

To accomplish this task in accordance with the MVVM pattern, bind the HeaderItemsSource property to a collection in your ViewModel and specify the HeaderItemTemplate or HeaderItemTemplateSelector.

Question Comments

Added By: Anurag Mahato at: 9/12/2016 1:29:49 AM    can you provide a small sample for Checkbutton
Added By: Alexander S (DevExpress Support) at: 9/12/2016 3:21:01 AM    

Hi Anurag,

I've created a separate ticket on your behalf (T426040: How to add CheckButton before DXWindow's default buttons). It has been placed in our processing queue and will be answered shortly.

How to change a page language at runtime (jQuery approach)

How to scroll TableView on selecting row with moving the mouse outside view bounds

$
0
0

Obsolete. Starting with 12.1, to achieve this functionality, set the GridControl.SelectionMode property to Cell. 




This example illustrates how to add the DXGrid behavior which provides the capability to select rows and cells by simply moving the mouse over them with the mouse button pressed and auto-scrolling the view in a necessary direction.

This functionality was implemented via attached behavior for DXGrid which encapsulates all the selection functionality.

The scrolling functionality was implemented in a separate class named ScrollController.

Question Comments

Added By: MichaelDaly at: 10/15/2012 5:51:50 AM    

This example needs more testing.

Line 207: rightColumnWhenUnselect can be null, need to insert this before: if (rightColumnWhenUnselect == null) rightColumnWhenUnselect = View.VisibleColumns.Last();

Line 181: CurrentSelectionInfo.Column can be null

It's a good effort, but the scrolling does not feel as smooth as in other apps, e.g. Excel

Added By: MichaelDaly at: 10/15/2012 5:53:21 AM    

Note: previous comment was for code in GridSelectingBehaviour.cs

Added By: Andrey K (DevExpress Support) at: 5/7/2015 10:19:21 AM    Hello,

It seems that your message was lost in our Support Center. Thank you for your remarks. We will improve our example accordingly.

Thanks,
AndreyAdded By: Mario Seitz at: 9/12/2016 5:01:16 AM    Does not work with v16 anymore.

After updating I had to change:

Column.Width

to

Column.Width.Value

Added By: Elliot (DevExpress Support) at: 9/13/2016 2:04:32 AM    

Hello Mario,

I've created a separate ticket on your behalf (T426562: How to use the E2725 code example in version 16.1?). It has been placed in our processing queue and will be answered shortly.

How to reorder ASPxGridView rows using buttons or drag-and-drop

$
0
0

This example demonstrates how to move ASPxGridView rows using buttons or jQuery Drag&Drop.


To keep the order of rows, it is necessary to set up an extra column to store row order indexes. Then, sort ASPxGridView by this column and deny sorting by other columns. This example stores this information in the unbound column and additionally puts a dictionary "row key = row index" to the session. We have implemented this approach only for demo purposes. You can store this information in your DataSource.

Updated:

We updated an example for v.14.2 to show how to save order information to a database and tune the ASPxGridView drag and drop appearance using the UI Draggable and Droppable plug-ins. If you need to check the unbound column  implementation, choose the second item in the version build combo box. 

 

See also:
T191258 - How to reorder GridView rows using buttons or drag-and-drop

E1810: How to use jQuery to drag and drop items from one ASPxGridView to another

E3850: How to reorder ASPxTreeList sibling nodes, using buttons or drag-and-drop
E4299: How to move up or down a line a row of ASPxGridView by using external buttons

Question Comments

Added By: Hiren Joshi (Venture) at: 8/20/2013 3:03:21 PM    

Hello,

I have seen your example however I have a question from user view point. Once you start to drag a row button you don't have any way to tell which row you are dragging. So unless you remember the row to started with it will be diffcult for users to use this practically. Do you have a way to drag the entire row or have a button with some text to identify the row you are dragging? Please let me know if this is possible.

Added By: Jacob Blumberg at: 8/27/2013 4:05:00 PM    

I agree, that is what I am looking for too.

Added By: Hiren Joshi (Venture) at: 9/11/2013 10:54:22 AM    

I was able to use the link tag <a href=""><%#Eval("YourData")%></a> instead of the image; in order to over come the problem of knowing which row is being dragged. So now when I drag the row I can see the text that I am dragging.

Added By: Wouter Stichelbout at: 2/11/2014 7:54:23 AM    

I there an MVC equivalent?

Added By: Vasily (DevExpress Support) at: 2/11/2014 9:48:17 AM    

Hi Wouter,

I have extracted your question to a separate ticket created on your behalf: Q466606: GridView - How to reorder GridView rows using buttons or drag-and-drop.
Your time and cooperation are appreciated.

Added By: Walter Rijk at: 6/23/2014 1:45:25 AM    

Hello,

This approach much more resembles the way Telerik has implemented row dragging and dropping:

       function InitalizejQuery() {
           var openhand = "url(https://mail.google.com/mail/images/2/openhand.cur), move";
           var closedhand = "url(https://mail.google.com/mail/images/2/closedhand.cur), move";

           $('.dxgvDataRow, .dxgvFocusedRow').each(function () {
               $(this).css({ "cursor": openhand });
           });
           $('.dxgvDataRow, .dxgvFocusedRow').draggable({
               helper: function () {
                   var result = $("<table class='dxgvTable' cellspacing='0' cellpadding='0' style='opacity:0.7;background-color:#dddddd;'>").append($(this).clone()).append($("</table>"));
                   $("td", this).each(function (index) {
                       $("td", result).eq(index).css({ 'width': $(this).width() });
                   });
                   return result;
               },
               axis: "y",
               start: function (event, ui) {
                   $("tr", $(this).parent()).each(function (index) {
                       $(this).css({ "cursor": closedhand });
                       $(this).removeClass('dxgvFocusedRow'); // this is the same as removing the focussedrowindex
                       $(this).addClass('dxgvDataRow');
                   });
                   $(this).addClass('dxgvFocusedRow');
               },
               stop: function (event, ui) {
                   $(this).css({ "cursor": openhand });
               }
           });
           $('.dxgvDataRow, .dxgvFocusedRow').droppable({
               drop: function (event, ui) {
                   var draggingRowKey = ui.draggable.find("input[type='hidden']").val();
                   var targetRowKey = $(this).find("input[type='hidden']").val();
                   gridView.PerformCallback("DRAGROW|" + draggingRowKey + '|' + targetRowKey);
               }
               , over: function (event, ui) {
                   var targetRowKey = $(this).find("input[type='hidden']").val();
                   var rowindex = gridView.keys.indexOf(targetRowKey);
                   window.setTimeout(function () { gridView.MakeRowVisibleNew(rowindex); }, 100);
                   $(this).addClass('borderClass');
               }
               , out: function (event, ui) {
                   $(this).removeClass('borderClass');
               }
           });
       }

Best Regards,
Ernstjan Freriks

Added By: Kchouk at: 12/8/2014 2:00:35 PM    

I am having difficulties figuring out how to actually use a field from the datasource to save the sorting order. Any help will be appreciated.

Added By: Artem (DevExpress Support) at: 12/9/2014 12:17:45 AM    

Hello,

To process your post more efficiently, I created a separate ticket on your behalf: T184636: ASPxGridView - How to save sort order to a database using approach from the E4582. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Gregory Lange 1 at: 4/9/2015 12:28:22 PM    

Just a suggestion you should also make these for where people load data via datasource in the code behind because trying to translate this sometime to that things get messed up.

Added By: Anthony (DevExpress Support) at: 4/9/2015 1:07:37 PM    

Hi Gregory,

You are always welcome to create a support ticket if you have difficulties in implementing approaches from our examples.

Added By: Michael Herron at: 9/2/2015 9:28:02 AM    

This example does not work if used within a MasterPage. Has anyone tried this?

Added By: Artem (DevExpress Support) at: 9/2/2015 1:14:20 PM    

Hello Michael,

To process your recent post more efficiently, I created a separate ticket on your behalf: T285292: E4582 doesn't work if ASPxGridView in on a MasterPage. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Wendy so at: 9/14/2016 1:31:35 AM    Hi Dev Express Support,

I have go through your example code below, it work fine for my case. But unfortunately after I add second grid view, it not work fine. How to modify the InitalizejQuery() in order to randomly get the current grid view being drag.

Note: I do not drag from one row in one grid view to another grid view. Only drag inside its own grid view.

Appreciated if you can provide me the solution rapidly. Thank you.
Viewing all 7205 articles
Browse latest View live


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