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

How to add a custom title to a map vector element

$
0
0

This example illustrates how to add a title to a map's dot.

To accomplish this, create a ShapeTitleOptions object and assign it to the MapShape.TitleOptions property. Then, specify the title's text via the ShapeTitleOptions.Pattern property.

Note that the title's text can be invisible on a map. So make sure the ShapeTitleOptions.Visible property is set to true.

Question Comments

Added By: Tony Johnson 2 at: 10/13/2014 9:15:18 PM    

For some odd reason using this approach in code behind - after shapetitleoptions.pattern is assigned the dot.tooltippattern fails to display when the dot is clicked.  It becomes an empty black box.   Removing the titleoption restores the tooltippattern normal display behavior.

Added By: John (DevExpress Support) at: 10/13/2014 10:05:14 PM    Hi Tony,
It seems that you have already asked this question in a separate ticket:Changing a Map Dot title via shapetitleoptions.pattern in code behind seems to delete tooltippattern. Let's continue the conversation there.

How to connect different ORM data models to several databases within a single application

$
0
0

Scenario

This example demonstrates how to create custom XAF modules with custom business objects and logic that would work with separate databases. These modules do not depend on each other and thus can be reused in other applications as a whole.
Usually, the connection to the database is set up in the executable application project. Typically, it is performed in the configuration file or directly in the code of the application's designer or within the Main function/Global application class. To learn more, please check out this help topic: Connect an XAF Application to a Database Provider In this example, you will learn how to establish a connection to the database directly from your module projects.


Steps to implement

0. Create a new XAF solution using one of predefined project templates;

1. Add two XAF modules into this solution using the DevExpress vXX.X XAF Module project template;

2. Add required persistent classes into these modules as shown in the ClassLibraryN/PersistentClassN.xx files of this example solution;

3. Add service ModuleInfo classes into these modules as shown in the ClassLibraryN/ModuleInfoN.xx files of this example solution;

4. In YourModuleName/Module.xx files, override the Setup(XafApplication application) methods of the ModuleBase descendants to handle the CreateCustomObjectSpaceProvider event of the XafApplication class as shown in the ClassLibraryX/XafModuleN.xx files of this example solution;

5. Build the solution, invoke the Module Designer for the platform-agnostic module (YourSolutionName.Module/Module.xx), and drag the created custom modules from the Toolbox:

Alternatively, you can add the same modules via the Application Designer invoked for the executable projects (as demonstrated in this example).

6. Declare connection strings in the configuration files of your application as shown in the TwoXpoModelsForDifferentDatabases.Web\Web.config and TwoXpoModelsForDifferentDatabases.Win\App.config files (see ConnectionStringDatabaseX under the <connectionStrings/> element). These connection strings are used in the modules via the ConfigurationManager.ConnectionStrings API, but you can always modify the way your modules obtains this data.

Important notes

1. Each module has a single static XPObjectSpaceProvider instance, which is initialized only once during the application life cycle.
2. Each ModuleUpdater class checks whether it is valid to create initial data of a certain type from this module via the IObjectSpace.CanInstantiate method.
3. Business classes linked to different ObjectSpaceProviders are considered to be isolated from each other and thus cannot have any links between them (e.g., have an association). Consider using the How to prevent altering the legacy database schema when creating an XAF application or alternative solutions if you need interlinks between classes from different data stores.

4. If several XPObjectSpaceProvider objects are connected to the same database, then it would be necessary to additionally map the service XPObjectType class to different tables in each XPDictionary. You can do this in the application_CreateCustomObjectSpaceProvider method by adding DevExpress.Xpo.PersistentAttribute with a modified mapping: 

[C#]
...XPClassInfoci=typeInfoSource1.XPDictionary.GetClassInfo(typeof(XPObjectType));if(ci!=null){ci.RemoveAttribute(typeof(PersistentAttribute));ci.AddAttribute(newPersistentAttribute("Service_XPObjectType1"));}...


See also:
How to prevent altering the legacy database schema when creating an XAF application

How to print from RichEditDocumentServer in WPF application

$
0
0

This example utilizes the DevExpress.XtraRichEdit.Printing.XpfRichEditPrinter descendant to print the document loaded into the RichEditDocumentServer instance. A custom method iterates all available printers and chooses the one that contains a word "Canon" in its name.
Starting from v2014 vol.1.8 (and also v2013 starting from vol.2.12) the DevExpress.XtraRichEdit.Printing.XpfRichEditPrinter class is not capable of creating fixed documents from the RichEditDocumentServer instance. A new class RichEditDocumentXpfPrinter should be used instead. The updated example utilizes the RichEditDocumentXpfPrinter.CreateFixedDocument method to create a fixed document.

How to invoke a Print Preview dialog and print a document from RichEditDocumentServer

BarManager - How to show both check mark and glyph in BarCheckItem

$
0
0
This example demonstrates how to override default painting mechanism of the BarCheckItem so it allows showing both check mark and glyph. Glyph in this case will be shown at the right side of the BarCheckItem's caption.


ASPxMenu - How to show a sub menu with a full page width

$
0
0

While our team is still working on this functionality in the context of the ASPxMenu - Provide an option to show a sub menu with a full page width  thread, you can accomplish this task in the following manner: 


1) Assign the following CSS class to the SubMenuStyle.CssClass property: 
[CSS]
.subMenu{width:100%;box-sizing:border-box;}.subMenu>div{margin:0auto;}

2) Handle the client-side PopUp event to adjust a sub menu:

[JScript]
function OnPopup(menu, e){var el = menu.GetMenuElement(e.item.indexPath); el.style.left = 0; el.style.right = 0; el.style.width = '100%';} 

The example below demonstrates this approach in action.

How to implement data paging

$
0
0

Silverlight supports the data paging mechanism natively. In the meantime, there are no easy approaches to implementing the IPagedCollectionView interface in WPF.


The easiest way to implement data paging is to change the grid's ItemsSource when the page index is changed. This example contains special attached behavior that allows you to enable this feature with ease.

Question Comments

Added By: Ravickumar Murugesan at: 8/23/2013 3:00:35 PM    

With this implementation the search behavior is not normal.

Added By: Alexander (DevExpress Support) at: 8/25/2013 11:27:33 PM    

Hello,

I have checked the Search Behavior with this solution using version 13.1.6, and it appears that everything works as expected. Searching operates only for the current page. If you have other behavior on your side, would you please describe the issue in greater detail?
P.S. Please create a separate ticket to clarify this moment. If we find an issue with the provided solution, we will update it.

Added By: f22raptor at: 2/4/2014 9:53:13 AM    

I getting NULL exception at this line:
 DataPager.ItemCount = Sources.Count;

Added By: Michael Ch (DevExpress Support) at: 2/5/2014 6:19:48 AM    

Hello,

We have moved your question to a separate thread: Q466351 thread. Please refer to it for further discussion.

Added By: kumar gaurav 8 at: 8/7/2014 11:51:08 PM    

this solution is not working because the GetValue(sourceproperty) gives null

Added By: Alexander (DevExpress Support) at: 8/8/2014 2:37:17 AM    

Hi Kumar,

I've noticed that there is a separate thread with the same question from you: How to implement paging in dxg:GridControl using dxe:DataPager. We will answer in that ticket as soon as possible. Please give us some time.

Added By: Candy lei at: 10/15/2014 1:02:17 AM    

How could I add the datapager in the footer of the gridControl. I add it to the FooterTemplate of the tableview , but it can't works well. What should I do?

Added By: Nadya (DevExpress Support) at: 10/15/2014 3:01:53 AM    

Hi, Candy

We have moved your question to a separate thread: T161457 - How to add DataPager in the GridControl footer . Please refer to it for further discussion.

How to replace the current cell value with a parent total value if a corresponding total row has a single child Field Value

$
0
0

If you use the PercentOfColumn SummaryDisplayType, it is sometimes necessary to show total values in the last level cells. Refer to the attached screenshot. Red cells show a percent of the corresponding total value, but since the total has a single nested cell, 100% is always shown. In this case, the only way to see the total value (a green cell ) is to collapse the corresponding row:


f you wish to always see total values, simply enable the PivotGrid.OptionsView.ShowTotalsForSingleValues Property. In this case, total rows will be always shown:



However, these extra total rows take additional space. Sometimes it is better to show corresponding total values instead of the default cell value. This example demonstrates how to accomplish this task.


Note that this example uses our internal API to access all required information about the processed row. We do not update this API frequently but since these are our internal methods, we can change them without any notifications. It is necessary to test this functionality carefully on each version update.




ASPxGridView - How to filter a column via ASPxTokenBox and allow selection of the filter operator

How to fix a row in GridControl

$
0
0
This example demonstrates how to provide the capability to fix a row in GridControl.
Our GridControl doesn't have the capability to fix a row. So, to provide this capability in this sample, we manipulate
the child collection of the HeirarchyPanel. We add a StackPanel with a collection of editors to the child
collection of the HeirarchyPanel and bind them to respective cells of the selected row. Then, we assign
it to a ScrollChanged event of the ScrollViewer. When ScrollChanged raises, we change the location of the StackPanel, so it is always displayed on the top of the grid view.
Please note, that this approach is not compatible with Bands and Conditional Formatting. Also, a fixed row may not be displayed immediately when PerPixelScrolling is enabled.

ASPxGridView - How to use the TokenBox in a Filter template to filter grid's TokenBoxColumn

How to extract images from a PDF document at runtime

How to find free time intervals for a meeting arrangement

$
0
0

This example illustrates the use of FreeTimeCalculator class to find all available free intervals within the specified period of time. Also, it can be used to find the nearest free slot with the specified duration.
When the FindFreeTimeInterval method finds an interval that does not intersect with existing appointments, the IntervalFound event occurs. We handle this event to exclude intervals which fall into restricted areas, such as non-working hours or holidays.

This application finds a free slot with specified duration within the work time before the end of the current work week. The non-working time is defined in code as an interval from 6 PM current day to 8 AM next day.The project uses SQL Server so the corresponding detached database files - XtraScheduling.mdf and XtraScheduling_log.ldf are included. You should attach the databases to the MS SQL server and change a connection string in the app.config file before running the project.

Question Comments

Added By: J S 16 at: 10/15/2014 12:28:22 AM    

Hi,

I'm trying to implement this example but vs2013 (.net 4.5) throws an error that the name 'slotDuration' does not exist in the current context.

Regards,
Jan

Added By: Andrey (DevExpress Support) at: 10/15/2014 5:21:10 AM    

Hello,
I tried to reproduce this behavior, but without success. In the attachment, you will find a sample video which demonstrates how it works on my side.
Would you please clarify whether you make changes in the example code? 

Added By: J S 16 at: 10/15/2014 7:12:03 AM    

Thanks for your reply.

Solved it...missing namespace

Added By: Andrey (DevExpress Support) at: 10/15/2014 7:45:40 AM    You are welcome.

How to create custom report controls

$
0
0

The following example demonstrates how to create a custom ProgressBar control.

In this example, the progress bar control is implemented as a filled rectangle with variable width, and serves as a graphical representation of a numerical value. This custom control has two primary properties - Position and MaxValue. The Position property determines the current progress for the value tracked by this control (how much of the bar is filled in with the progress color). The MaxValue property determines the maximum value for the Position property and the scale used by the progress bar. Note that the Position property is bindable, which allows the progress bar control to be used in data-aware reports.

Question Comments

Added By: Jignesh Suthar at: 4/18/2013 10:26:52 AM    

How do I specify editor for the Numeric property in below example?

Added By: Wolfgang Lautner at: 7/31/2014 7:02:23 AM    

I tried this example and when changing the base class from XRLabel to XRControl, then also the "Preview" worked (exception unable to cast PanelBrick to LabelBrick)

Then I tried to make a custom control how described in the tutorial "How to: Create a Progress Bar Control", but when loading the DLL to add the control to the toolbox, it failed with the error "There is no components in '...dll' that can be placed on the toolbox.

Any idea what is going wrong or can you provide an example project to build a working control dll?

Regards, Wolfgang

Added By: Vasily (DevExpress Support) at: 7/31/2014 10:31:56 AM    

Hi Wolfgang,

To process your recent post more efficiently, I created a separate ticket on your behalf: T135838: How to create a custom report control and register in in the ToolBox. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Justyn Laufenberg at: 10/14/2014 1:35:29 PM    

When the report is saved and loaded again, if max value was set to something besides 100, it doesnt save. Is there a way to get the properties to save as part of the xml? I am using the end user side of reports and need the custom properties to save when 'SaveLayoutToXml' is called.

Added By: Ingvar (DevExpress Support) at: 10/15/2014 1:27:43 AM    Hi Justyn,

Make sure that you have marked your properties with the XtraSerializableProperty attribute.

See also:
XML SerializationAdded By: Justyn Laufenberg at: 10/15/2014 8:06:27 AM    

Awesome, easy fix. For others reference.

       [DefaultValue(100), XtraSerializableProperty]
       public float MaxValue {
           get { return this.maxVal; }
           set {
               if (value <= 0) return;
               this.maxVal = value;
           }
       }

Added By: Justyn Laufenberg at: 10/15/2014 9:21:19 AM    

Another Question, how do we set what the display name of the control will be in the toolbox?

For the properties, I was able to do the following.
[DisplayName("Max Value")]
[Description("The max value of the bar.")]

But the same doesn't work for the control. I would like it to say "Progress Bar".  Currently, I am doing the following but is a little tedious and would like to know if there is a better way.
ToolboxItem progressBar= new ToolboxItem(typeof(ProgressBar));
progressBar.DisplayName = "Progress Bar";
ts.AddToolboxItem(progressBar, "Custom");

Thank You.

How to use TreeList for file management (drag and drop files and folders)

$
0
0

This example is based on the Explorer module contained within the TreeListMainDemo sample project. It illustrates how to implement the Drag and Drop functionality in TreeList, which will also allow the moving of actual folders and files. To implement such Drag and Drop functionality, handle CalcNodeDragImageIndex to customize an image to be dragged and the DragDrop event to implement custom drag logic, as well as the logic of moving files and folders.

Question Comments

Added By: Christian King 1 at: 10/15/2014 10:07:36 AM    

Do you have a version of this example done in ASP.net instead of WinForms?


How to display detail views under each other

$
0
0

By default, the grid displays detail views on tab pages. If there are several child views at the same level, only one can be seen at a time - the one that appears on the selected detail tab.

You may wish to add an additional level (GridView) to display a list of relations and allow a user to expand them, to see the actual detail under one other. This example demonstrates how to implement this feature by handling the MasterRow~ events.

Question Comments

Added By: sandra ruiz 1 at: 1/3/2013 7:23:14 AM    

am I missing something or this example is incomplete? thanks.

Added By: Peter Thornton at: 4/3/2013 7:30:36 AM    

This really is a bad solution. Why shoud developers have to cope with fake views and a bunch of events to show multiple details under eachother? This is something even the most basic grids can do.

How come you haven't made this a feature yet?

Added By: Jannet (DevExpress Support) at: 10/15/2014 10:59:02 AM    Hello Sandra and Peter, 
We will review this example and get back to you ASAP. Please stay tuned.

MVC ComboBox Extension - Cascading Combo Boxes

$
0
0

This example illustrates how to implement cascading combo boxes scenario within the MVC ComboBox Extension.
It is an illustration of the KA18675: MVC ComboBox Extension - How to implement cascaded combo boxes KB Article. Refer to the Article for an explanation.

The example contains the following solutions:
- The solution for v2011 vol 2.10+ builds - MVC3 / Razor View Engine
- The solution for v2010 vol 2 - v2011 vol 2 builds - MVC2 / ASPx View Engine (obsolete)

Question Comments

Added By: SDBala at: 11/14/2013 7:54:04 PM    

The example attached seemed to populate the cascading combo's correctly, however in the Create (HTTPPost method) both of the them don't seem to contain the values that i selected. i.e. the when i check the model parameter in the Create method they don't contain any values.

What could be the possible reason

Added By: Jeeva P at: 3/6/2014 2:28:04 AM    

How to set Country combobox as checked combobox?

Added By: Mr Price Group Ltd Mr Price Group Ltd at: 3/17/2014 3:18:09 AM    

After struggling to apply this to my project, I think what needs to be stressed here is the fact that, apart from the @model reference, the combobox and only the combobox must be in the partial view so that the framework knows what to update.

I had a <div> tag surrounding the a label element and the combobox and the callback was displaying a popup message with my results. After moving those out of the partial view, the combobox updated correctly.

Added By: Faye Spath at: 6/12/2014 1:23:51 PM    

How can I set the selected value  of city dropdown upon selecting a country ?

Added By: Sergi (DevExpress Support) at: 6/12/2014 11:42:54 PM    Hi Faye,

I have created a separate ticket regarding your question: T118096: ComboBox Extension - Cascading Combo Boxes - How to set initial value

How to convert the CriteriaOperator to a lambda expression, so, the latter expression can be used in the IQueryable source

$
0
0

Imagine, that an end-user can build a filter criteria, e.g. by using the FilterControl, and you wish to apply this filter criteria to your IQueryable source.

The static DevExpress.Data.Linq.Helpers.CriteriaToQueryableExtender class allows you to add extended methods for the IQueryable source, such as AppendWhere method, for example. This method provides a capability to create a new IQueryable source, based upon the existing one, and add an additional Where condition to it. So, you can convert the CriteriaOperator to the corresponding lambda expression without any problem.

To extend the IQueryable source, it is sufficient to add the DevExpress.Data.Linqassembly to the References list and add the DevExpress.Data.Linq.Helpers namespace.

Please note that the DevExpress.Data.Linq.Helpers.CriteriaToQueryableExtender is an inner class, and we cannot guarantee that it will not be changed in the future.

How to specify custom background for DXEditors

$
0
0

In our themes, the Control.BackgroundProperty is defined by several elements with different colors, gradients, margins, paddings and corner rounding. You can't specify this complex functionality with only the Control.BackgroundProperty property. You can implement your own template using the TextEditThemeKey key ({dxet:TextEditThemeKey ResourceKey=BorderTemplate}). Also, you need to bind to the Background property.

How to show/hide a custom button in an editor

$
0
0

Update:
Starting with version 10.2.10, you can use the ButtonInfo.Visibility property to hide/show a custom button.


This sample illustrates how to show/hide a custom button in the ComboBoxEdit. Inherit from the ButtonInfo, and implement the ButtonInfoVisibility dependency property. Implement the ButtonInfo template, and bind the Button.Visibility property to the ButtonInfoVisibility property. We plan to implement this property: S35955

Viewing all 7205 articles
Browse latest View live


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