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

How to edit properties of multiple objects in a single PropertyGridControl

$
0
0

This example shows how to edit properties of different objects in a single PropertyGridControl. Properties to be edited are provided via the CustomPropertyDescriptors event.

Question Comments

Added By: Stefan Kloss at: 2/3/2017 12:41:50 AM    I don't see that this exanple does what it says.
It edits Properties of ONE Object, the Form, not of multiple objects. This is pretty useless for the names task.


How to set a GalleryControl as a custom drop-down for the TokenEdit

$
0
0
This example illustrates how to replace a standard TokenEdit drop-down menu with a GalleryControl.
You can also refer to this example that uses a TreeList control for the same purpose.
Question Comments

Added By: Robert Schweins at: 2/3/2017 2:31:45 AM    c# and vb.net samples not working.
Devexpress version 16.1.7

How to locate field value cells matching a particular condition

$
0
0

The following example demonstrates how to handle the CustomFieldValueCells event to locate a specific column/row header identified by its column's/row's summary values.
In this example, a predicate is used to locate a column that contains only zero summary values. The column header is obtained by the event parameter's FindCell method, and then removed via the Remove method.

How to create fully custom Role, User, Event, Resource classes for use with the Security (old) and Scheduler modules

$
0
0

This example demonstrates how to create fully custom classes for use in our Security Module (with the 'old' DevExpress.ExpressApp.Security.SecurityComplex component) and Schedule Module:
    - Activity is an analog of our standard Event class that is used to represent appointments in the Scheduler Control.
    - Employee is an analog of the standard User class, which also supports the IResource interface to use objects of this class as resources in our custom appointment above.
    - Group is an analog of our standard Role class
To enable these two custom security classes in your application set the RoleType and UserType properties for the SecurityComplex component within the Application Designer.

Additionally, the two popular filtering tasks are implemented: filtering appointments by the current logged employee and also filtering resources to show only those owned by the current logged employee.
This functionality is provided by the SchedulerActivityListViewControllerBase class and its descendants as follows:
   a. Administrator account (Sam, to log on, leave the Password field empty) sees all the resources and appointments in the root scheduler view.
   b. Non-Administrator account (John, to log on, leave the Password field empty) sees only his own resources and appointments in the root scheduler view.
   c. Both Administrator and Non-Administrator accounts see their own resources and appointments in the nested scheduler view.
You can use SchedulerActivityListViewControllerBase  and related controllers for study purposes, since they demonstrate the most common filtering scenarios in the scheduler view. If you do not need all this specific functionality, simply remove these controllers and create your own ones (perhaps based on the provided example code) that will do only your specific task. For example, the controllers from this example are not suitable in the nested scheduler view because you miss some part of the default Link/Unlink functionality since the scheduler view is always filtered to show only its own resources and appointments.That may not be desired because you may want to have the capability to link appointments from other resources, but they won't be shown due to the above. Plus, these demo controllers are unnecessary for appointments filtering in the nested scheduler view, because by default, in this view only appointments from the current resources are shown.

Important notes

1. Example implementations are NOT designed for the 'new' security system components and scenarios (e.g., middle-tier application server or SecuredObjectSpaceProvider). To use the SecurityStrategyComplex component, provide fully custom implementations of the user and role classes as per the eXpressApp Framework > Task-Based Help > How to: Implement a Custom Security System User Based on an Existing Business Class article.

2. The Activity (appointment) and Employee (resource) classes' code was once created based on the code of the default Event and Resource classes from our DevExpress.Persistent.BaseImpl library. This example code should not be used with v15.2 or newer. It is necessary to update the code of the Activity and Employee classes based on the ...\Sources\DevExpress.Persistent\DevExpress.Persistent.BaseImpl\ library sources according to changes made in the latest XAF versions (15.2+).

3. The IEvent and IResource members are used for appointment and resource mappings and should be declared as public properties. Both XPO and Entity Framework consider public writable properties as persistent (mapped to database columns). If you want to map these properties to columns with different names, use the Persistent or Column attributes in XPO and Entity Framework correspondingly. Alternatively, you can manually calculate property values and decorate interface members with the NonPersistent or NotMapped attributes to specify that these properties are not mapped to columns in the database. If you do not want interface members to be visible in views, use the VisibleInListView, VisibleInDetailView, and VisibleInLookupListView attributes correspondingly.

Question Comments

Added By: Ad de Rijke at: 5/19/2014 4:52:28 AM    

The Web project does not compile: 'The type or namespace name 'WinWebSolutionAspNetApplication' could not be found (are you missing a using directive or an assembly reference?)'

Added By: Dennis (DevExpress Support) at: 5/20/2014 3:31:16 AM    @Ad: For some reason the WebApplication.cs file was emptied. I have attached a working sample for your reference. I will also update this example as well.Added By: Ville Virtanen at: 12/4/2015 11:06:39 PM    

When trying to run it gives an error: Another rule with ID = 'EventIntervalValid' already exists.

When I commented following lines, it worked, but how I disable the BaseImpl rule?

//[NonPersistent]
       //[Browsable(false)]
       //[RuleFromBoolProperty("EventIntervalValid", DefaultContexts.Save, "The start date must be less than the end date", SkipNullOrEmptyValues = false, UsedProperties = "StartOn, EndOn")]
       //public bool IsIntervalValid { get { return StartOn <= EndOn; } }

Added By: Dennis (DevExpress Support) at: 12/7/2015 5:41:37 AM    

@Ville: You can simply rename this rule without commenting it out to avoid this error. Or, you would better not to use the default Event class from the DevExpress.Persistent.BaseImpl library in your project.

Added By: Nate Laff at: 2/17/2016 7:43:43 AM    Can we see an update to this for 15.2? Things are currently pretty broken. In Activity.UpdateEmployees() the XML is coming back much different than it previously did.Added By: Dennis (DevExpress Support) at: 2/17/2016 8:09:23 AM    

@Nate: We will unlikely update this code for v15.2 for the reasons described in point #2 of the important notes to this example. The example's Activity class code is pretty much the same as the code of the Event class (similarly, Employee is an analog of the Event's Resource and security User classes) and we would like to avoid synchronization and maintenance problems for our users going forward.

In the future, I will probably rework this article to be more like a codeless KB article that would focus not on specific implementations, which are different for each concrete business scenario, but rather on the main points of such an integration, which are the same for all cases. I hope this makes sense.

Added By: Paul van Keulen at: 5/25/2016 3:56:20 AM    While compiling this project it gives an error: Error 1 The type or namespace name 'IXpoCloneable' could not be found (are you missing a using directive or an assembly reference?)
Added By: Paul van Keulen at: 5/25/2016 4:01:17 AM    When I remove the IXpoCloneable code I can compile.
After creating an event:

Employee activityUser = Session.GetObjectByKey<Employee>(new Guid(xmlNode.Attributes["Value"].Value));

raises an error.

I'm using 15.2.5. Added By: Dennis (DevExpress Support) at: 5/25/2016 4:14:18 AM    

@Paul: This example code should not be used with v15.2 or later (the version selection is also limited via the example's web page UI). Please refer to point #2 under the Important notes section to learn more on how to proceed with the latest versions. Let us know in case of any further questions on how to apply this guidance.

Added By: Ville Virtanen at: 8/12/2016 2:59:33 PM    Do you plan to update this example to latest version?
Added By: Michael (DevExpress Support) at: 8/15/2016 12:22:42 AM    @Ville: It is unlikely that we will update this example, because the old security system is rarely used nowadays. As mentioned in the description of this ticket, you can find the actual implementation of the Event and Resource classes in the source code shipped with components. As for creating custom security classes, refer to the articles mentioned in the New Security System help topic.

How to implement the Drag&Drop functionality for the CardView

$
0
0

We have created an example demonstrating how to implement the Drag&Drop functionality for the CardView.

This functionality is encapsulated in the CardDragDropManager class. So, all you need to do is to attach this behavior to the GridControl.

Question Comments

Added By: A Dev at: 10/24/2014 12:19:57 PM    

Where to find the DragDropManagerBase class?

Added By: Ivan (DevExpress Support) at: 10/24/2014 12:47:27 PM    

You can find this class in the C:\Program Files (x86)\<DevExpress folder>\Components\Sources\DevExpress.Xpf.Grid\DevExpress.Xpf.Grid.Extensions\DragDrop\DragDropManager\DragDropManagerBase.cs file. Note that this file will be installed regardless your subscription type. It's available for trial users as well.

Added By: Jobert Galamiton at: 9/21/2016 11:34:35 PM    Hi,

This doesn't work with the latest version. Please advise. Added By: Andrey Marten (DevExpress Support) at: 9/22/2016 1:37:14 AM    

Hello,

I've created a separate ticket on your behalf (T430564: The approach from E4616 does not work in v16.1.6). It has been placed in our processing queue and will be answered shortly.

Thanks,
Andrey

How to implement cascading MVC ComboBoxes for editing custom fields in a custom Appointment Edit form

$
0
0
This example illustrates a server-side technique of editing hierarchical custom appointment fields using cascading MVC ComboBoxes.
The main idea of implementing cascading MCX ComboBoxes was demonstrated in the following examples:
GridView - A simple implementation of cascading comboboxes in Batch Edit mode
MVC ComboBox Extension - Cascading Combo Boxes
In this example, we added two custom fields for appointments (CompanyID and ContactID) and two corresponding MVC ComboBoxes onto a custom Appointment Edit form. 
An approach for customizing the Appointment Edit Form for working with custom fields was described here:
How to create a custom Appointment form to work with custom fields (based on T153478)
Changing a value of the "CompanyID" combobox results in filtering data in the "ContactID" combobox.

How to calculate cumulative values in the Pivot Grid control

$
0
0

This example demonstrates how to include previous cell values in values of the next cell. To calculate cumulative values, set the PivotGridField.RunningTotal property of the corresponding field to true.

The PivotGridControl.AllowCrossGroupVariation property allows you to specify whether running totals are calculated independently within individual groups or for the entire Pivot Grid. 
In this example, you can use the corresponding check boxes to control the Pivot Grid behavior.

How to bind the Web Dashboard to an Object Data Source and supply it with data using the DataLoading event


How to bind the Web Dashboard to an Object data source

How to connect the Web Dashboard to an Excel workbook

How to connect the Web Dashboard to an OLAP cube

How to connect the Web Dashboard to an SQL database

How to display data which is being updated on another thread

$
0
0

Let's suppose that your data is being updated on another thread, by the timer in this example. You should take a special action to correctly reflect those changes in the grid - wrap them inside BeginDataUpdate/EndDataUpdate calls.

When using the MVVM pattern, it is not possible to call grid's methods directly from the view model. Your view model can provide additional events to expose such changes of its state to the view. There are OnAsyncProcessingStarted and OnAsyncProcessingCompleted events in this example. Now you can handle these events in the view and force the grid to stop/start listening for data updates before/after asynchronous data modifications.

Please note even though this approach requires several code lines in View's code-behind, ViewModel in this situation is completely independent from GridControl. Thus, this approach conforms the MVVM pattern.


UPDATED:


After we introduced Services, the same task can be implemented by creating a custom service (How to create a Custom Service). This service will have access to the GridControl in the View, and will contain the required BeginUpdate and EndUpdate methods. In these methods, GridControl's BeginDataUpdate and EndDataUpdate methods will be called.

Starting with v13.1.4, this example illustrates this approach.

 

Question Comments

Added By: Itamar Shoham at: 2/7/2017 1:38:22 AM    Hi.

1. You have a misspell - "ICustomServcie" should be "ICustomService"
2. Please also make it clear that the ViewModel must inherit DevExpress.Mvvm.ViewModelBase
otherwise, if it inherits DevExpress.Mvvm.POCO.BindableBase, the user must also implement DevExpress.Mvvm.POCO.IPOCOViewModel interface

How to use a custom UserControl as a tooltip

$
0
0

This approach is outdated. If you have 13.2 version or higher, please use our FlyoutPanel for this purpose.

This example demonstrates how to use any control as a tooltip for DevExpress controls. More information, you can find the GetActiveObjectInfo article.

Question Comments

Added By: Dalibor Carapic at: 2/7/2017 4:42:12 AM    I fail to see how this approach is outdated. There is nothing in the FlyoutPanel which indicates that it is a replacement for the tooltip.

dxList - How to create a list with multiple columns


How to change the Field Value Header appearance backcolor or draw it manually

$
0
0

If UserLookAndFeel.Style is equal to Skin, the XtraPivotGrid control uses the Skins technology to draw its content. With this approach, all headers are drawn using a specific bitmap provided by a corresponding skin element. The appearance back color settings have no effect in this instance. So, if you want to draw a field header using a custom color, you should draw the field header manually via the PivotGridControl.CustomDrawFieldValue event.

The DrawIndicator method can throw exceptions in versions 15.1.3 - 15.1.5. We have fixed this issue in the context of the DrawIndicator method call throws an exception after updating to 15.1.5 ticket.

How to: Store file attachments in the file system instead of the database

$
0
0

Scenario
The FileSystemData module provides the FileSystemStoreObject and FileSystemLinkObject classes that implement the IFileData interface for the use with our File Attachments module.
FileSystemStoreObject - this class enables you to store uploaded files in a centralized file system location instead of the database. You can configure the file system store location via the static FileSystemDataModule.FileSystemStoreLocation property.
FileSystemLinkObject - this class enables you to add soft links to real files instead of saving their contents to the database. Apparently, it is intended for use in Windows Forms applications only.

Refer to the following video to see this functionality in action: http://www.screencast.com/t/Xl1GMfxw

Steps to implement
1. Copy and include the FileSystemData project into your solution and make sure it is built successfully.

2. Invoke the Module Designer for the YourSolutionName.Module/Module.xx file by double-clicking it in Solution Explorer. Invoke the Toolbox (Alt+X+T) and then drag & drop the FileSystemDataModule component into the modules list on the left.
3. Define a FileSystemStoreObject or FileSystemLinkObject type properties within your business class as described in the eXpressApp Framework > Task-Based Help > How to: Implement File Data Properties article. Make sure to decorate the container business class with the FileAttachmentAttribute (to provide additional commands for working with files) and also do not miss the Aggregated, ExpandObjectMembers(ExpandObjectMembers.Never) and ImmediatePostData attributes for the new class properties. See the E965.Module\BusinessObjects\FileSystemStoreObjectDemo.xx and E965.Module\BusinessObjects\FileSystemLinkObjectDemo.xx  source files for examples. 

4. Make sure you do not override the DevExpress.Persistent.BaseImpl.BaseObject.OidInitializationMode property in your application and related modules, because the OidInitializationMode.AfterConstruction value is necessary for the correct operation of this module (in the example, the required default value is already set in the FileSystemDataModule class of this example module).
5. Modify YourSolutionName.Win/WinApplication.xx file to handle the CustomOpenFileWithDefaultProgram event of the DevExpress.ExpressApp.FileAttachments.Win.FileAttachmentsWindowsFormsModule class as shown in the E965.Win\WinApplication.xx file.

 

IMPORTANT NOTES
1.
The current version of this example does not support the middle-tier scenario. Refer to the Q476039 ticket for more details.

 

See Also:
File Attachments Module Overview
Working with links to files instead of storing their contents in the database
SQL Server FILESTREAM feature Overview

Question Comments

Added By: Roger Gardner at: 8/2/2012 4:36:37 AM    

-How to change FileStoreObject to work With Application server?
-How many files you can store in one folder and the system is not to slow?

Can this sample be upgraded with Application server and multiple folders in File Data Store folder?

Added By: Sander Mclean at: 8/22/2012 12:31:10 AM    

Thank you for your example, but could you upgrade this to VB.NET?

Added By: Martin Kraeuchi at: 10/12/2012 2:00:24 AM    

I tried to run this example but it crashes.
It occurs a fatal error when I try to append a file after creating a new "Standard File Data Demo" Item. The error occurs at the moment the file select box opens. I didn't found a way to debug it.
Do you have a glue what it could be?

My configuration:
Win7 64BIT, VS2010, v2012 vol 1.7, SQL Server Express 2008 R2

Thanks, Martin

Added By: Dennis (DevExpress Support) at: 11/29/2012 9:56:43 AM    

@Roger: I have not yet tested this module with the application server. It is a good idea, though. Thank you for your input, I have added it to my TODO list.

@Sander: It is quite complex a module to rewrite it in VB.NET, as well as maintain two versions later. Even though it is not in my immediate plans, you can either include the C# module project into your VB.NET solution (Visual Studio allows this) or rather use free or paid conversion tools.

@Martin: Thank you for your comment. Hm, it performs perfectly well for me. I also ran functional tests that passed locally. You are probably not using the latest version in this example. It would be great if you could create a separate ticket in the Support Center and attach the eXpressAppFramework.log file with the error details. Thank you in advance!

PS.
Sorry for the late reply, guys. In the future, it is better to submit a ticket directly via the http://www.devexpress.com/Support/Center/Question/Create link, if you experienced any difficulties with our tools.

Added By: ABRAMO ABRAMO at: 11/21/2013 11:44:40 AM    

Hi,
I'm working with Images in XAF application storing user image file to file system. So I'm using FileSystemStoreObject and It work fine for me. However, I've some problem!

one - I'd like split and save user images in FileData\<mykey1> folder where mykey1 depends by Business Objects instance1,
user images in FileData\<mykey2> folder where mykey2 depends by Business Objects instance2 and so on.
two - I'd like show stored images like Asp.net Images Slides Control or a link item in grid view to open images.

Do you have any suggestion or example?

Best regards,
Gaetano

Added By: Ricardo Granja at: 1/27/2014 4:36:39 AM    

Do vou have an exemple of this as a domain componente?

Regards,
Ricardo

Added By: xaero xy at: 6/2/2014 9:47:03 PM    

Did the "StandardFileDataDemo" store file attachments in database?

Added By: Dennis (DevExpress Support) at: 6/3/2014 2:24:48 AM    

@xaero: The StandardFileDataDemo class uses the FileData class that stores files in the database and which is a part of the standard delivery.

In turn, the FileSystemStoreObjectDemo class stores files in the file system with the help of custom IFileData implementations described in this example.

Added By: Steve Perks @ NSS at: 9/19/2014 4:11:17 AM    

Hi Dennis, thank you for the code - it works great in my web application (I'm only using the FileSystemStoreObject). I've made a mod to cover the case where the user has previously saved a business object and subsequently reloads it to edit the FileSystemStoreObject property, namely to pick a different file. In this case _tempFileName is not correctly populated and the old file is not deleted when the file is changed and the business object saved.

My solution was to add the following code to FileSystemStoreObject.cs

   protected override void OnLoaded()
   {
       base.OnLoaded();
       _tempFileName = this.RealFileName;
   }

Hope this helps others and perhaps you could update your code if you also feel this is a good solution.

Added By: Dennis (DevExpress Support) at: 9/19/2014 5:21:49 AM    

Thanks for sharing, Steve. Would you please either record a video showing how to replicate this behavior with the original example or create a functional EasyTest script covering this scenario? This will help me better understand the situation and make changes, if necessary. Thanks in advance! 

Added By: Steve Perks @ NSS at: 9/19/2014 5:47:52 AM    

Dennis, how shall I send the video? No attachments in this thread.

Added By: Steve Perks @ NSS at: 9/19/2014 6:09:35 AM    

It's ok about sending the video, I've decided to host it for a short while here: http://host21.co.uk/e965/

Added By: Dennis (DevExpress Support) at: 9/19/2014 6:13:09 AM    Thanks for your video, Steve. I will take this scenario into account  for future updates.Added By: Genesis Supsup 1 at: 12/30/2015 2:07:35 AM    

Does this already work using Application Server? Given the correct credentials, will this concept work with Dropbox (in replacement to File System)?

Added By: Alexey (DevExpress Support) at: 12/30/2015 9:27:28 PM    

Hello,

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

Added By: Joseph Kellerer 2 at: 2/26/2016 4:17:30 AM    Thank you for providing this code!
It works great.

I have enhanced the FileSystemStoreObject to have a Content property like in the BaseImpl.FileData class:

[C#]
[NonPersistent]publicbyte[]Content{get{returnFile.ReadAllBytes(this.RealFileName);}set{this.TempSourceStream=newMemoryStream(value);}}
Added By: CHRIS TSELEBIS at: 3/16/2016 7:27:47 AM    The deletion is not working correctly on the detailview.  I hit delete, filed is deleted but gets an error message saying "requested objects canot be loaded, because they are abasent in the data store....".  It works fine in the listview.  Please check.
Added By: Dennis (DevExpress Support) at: 3/17/2016 2:11:50 AM    @Chris: Thanks for your feedback. In the meantime, you can remove the DeferredDeletion(false) attribute declaration from the FileSystemStoreObject class as a solution.Added By: CHRIS TSELEBIS at: 3/17/2016 10:12:53 AM    Dennis,  is it possible to make the textbox(filename) bigger?  I tried to set the width and height on detailview and no success.  Right now it's just using one row and no way to set rowcount for this field.  I want the textbox to be bigger so it's easier for user to drag and drop on detailview.
Added By: Dennis (DevExpress Support) at: 3/18/2016 2:39:43 AM    

@Chris: To process your recent post more efficiently, I created a separate ticket on your behalf: T358143: How to set the width and height of the FileData PropertyEditor control. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates. For better tracking, please also use the https://www.devexpress.com/Support/Center/Question/Create service to submit new questions regarding this or any other XAF functionality. Thanks for your understanding.

Added By: Joseph Kellerer 2 at: 10/20/2016 5:37:28 AM    If I edit an oject which uses an FileSystemStoreObject
AND
change the file name,
the old file remained and was not deleted.


After I changed LoadFromStream method to
[C#]
voidIFileData.LoadFromStream(stringfileName,Streamsource){//Dennis: When assigning a new file we need to save the name of the old file to remove it from the store in the future.if(fileName!=FileName)// changed, old code was if (string.IsNullOrEmpty(tempFileName))tempFileName=RealFileName;FileName=fileName;TempSourceStream=source;}


it works.
Added By: Andrew L (DevExpress Support) at: 10/21/2016 5:48:53 AM    

Hello Joseph,

Thank you for your comment.
We will consider your use case and possibly incorporate the changes you suggested to this example.

Added By: Alan Pérez 1 at: 11/26/2016 4:19:09 PM    Hi, I'm using this code, but, i have the error when i want to attach a file > 2 Gb size, how can i remove this limitant?

if (value.Length > (long)int.MaxValue) throw new UserFriendlyException("File is too long");



Added By: Dennis (DevExpress Support) at: 11/28/2016 12:45:43 AM    

@Alan: I've created a separate ticket on your behalf (T455721: Increase default attachment size in E965). It has been placed in our processing queue and will be answered shortly.

SchedulerControl and SchedulerStorage Event Viewer

How to bind a spreadsheet to an MS SQL Server database (WPF Spreadsheet)

$
0
0
This example demonstrates how to bind a cell range on a worksheet to the sample Northwind database to load data from the Suppliers data table. To accomplish this task, the WorksheetDataBindingCollection.BindToDataSource method is used.
This application also enables end-users to add, modify or remove data in a data table. They can use the corresponding buttons on the File tab, in the Database group to edit the data and save their changes back to the database.
To insert new rows, a data entry form is used. The user should fill out the given data entry fields and click the Save cell to add a new record to the Suppliers data table. Clicking the Apply Changes button posts the updated data back to the database. To remove a record, the user should select the required Suppliers row on the worksheet and click the Remove Record button. The Delete dialog will be invoked asking the user to confirm the delete operation. 
To send the modified data to the connected database, the Update method of the SuppliersTableAdapter is used. 

How to create and customize custom axis labels

$
0
0
This example demonstrates how custom axis labels are created and customized in the Chart control. 
 
To add a custom axis label on the chart, create a CustomAxisLabel object and add it to the CustomAxisLabelCollection returned by the Axis2D.CustomLabels  property.

To show the custom label on the X-axis or Y-axis, specify an axis value that corresponds to the label position on an axis (using the CustomAxisLabel.Value  property) and to its content (via the CustomAxisLabel.Content property).

You can customize custom labels' appearance using the Foreground, FontFamily,  FontWeight, and FontStyle  properties for the AxisLabel object.

For more information about custom axis labels, see the Axis Custom Label topic.
Question Comments

Added By: Jeremy AB at: 2/8/2017 6:48:11 AM    Hi

How can I show argument content in the legend ?
I mean I created CustomAxisLabel but it is not showing me the content in the legend

Sincerly
Viewing all 7205 articles
Browse latest View live


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