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

How to create a custom DialogService with custom commands

$
0
0

It is possible to specify what buttons should be shown by a dialog form associated with DialogService by passing MessageButton to the ShowDialog method. Such buttons are limited to a predefined set of values (OK, OKCancel, YesNoCancel, and YesNo). If you wish to create custom buttons with your own captions and associate them with the necessary custom commands, create a custom DialogService and pass a list of UICommands to the ShowDialog method. 
This example shows how to implement such a service and register it. Here, by using a custom find dialog, you are able to locate the necessary record in the grid by using the data model's Id and focus it. 


How to reorder grid rows by drag and drop

$
0
0

This example extends the example provided in the How to allow an end-user to move the rows in a grid up and down if the grid is bound to a DataTable article and illustrates how to reorder rows by drag and drop.

Starting with version 17.2.4, you can attach Drag And Drop Behavior to GridControl to implement reordering. For this, handle the DragOver and DragDrop events of the corresponding behavior using the following code:

[C#]
DragDropBehaviorgridControlBehavior=behaviorManager1.GetBehavior<DragDropBehavior>(gridView);gridControlBehavior.DragDrop+=Behavior_DragDrop;gridControlBehavior.DragOver+=Behavior_DragOver;

 

[VB.NET]
Dim gridControlBehavior As DragDropBehavior = behaviorManager1.GetBehavior(Of DragDropBehavior)(Me.gridView1)AddHandler gridControlBehavior.DragDrop, AddressOf Behavior_DragDropAddHandler gridControlBehavior.DragOver, AddressOf Behavior_DragOver

In the DragOver event handler, calculate drag-drop parameters (InsertType, InsertIndicatorLocation, Action and Cursor) using the static DragOverGridEventArgs.GetDragOverGridEventArgs method:

[C#]
privatevoidBehavior_DragOver(objectsender,DragOverEventArgse){DragOverGridEventArgsargs=DragOverGridEventArgs.GetDragOverGridEventArgs(e);e.InsertType=args.InsertType;e.InsertIndicatorLocation=args.InsertIndicatorLocation;e.Action=args.Action;Cursor.Current=args.Cursor;args.Handled=true;}
[VB.NET]
PrivateSub Behavior_DragOver(ByVal sender AsObject, ByVal e As DragOverEventArgs)Dim args As DragOverGridEventArgs = DragOverGridEventArgs.GetDragOverGridEventArgs(e) e.InsertType = args.InsertType e.InsertIndicatorLocation = args.InsertIndicatorLocation e.Action = args.Action Cursor.Current = args.Cursor args.Handled = TrueEndSub

Data Source reordering logic should be implemented in the DragDrop event handler.

In older versions, reordering is implemented using the standard Drag events.

Question Comments

Added By: Micha Ben-Efraim at: 6/11/2012 2:11:54 AM    

I copied this example for reordering the element of a list bound to the control and it works almost perfectly. The problem is that the control doesn't scroll during D&D: the list is longer as the displayed window. If I select the first or the last item in the list (first/last row) and want o move to the last/first position, which is not visible, the view should scroll somehow in order to show the target drop row. But it doesn't do it when I move the cursor to the top/bottom of the view.
Can it

Added By: Fmonteiro at: 11/5/2013 3:34:26 AM    

Is possible to make this with the AdvBandedGridView?
I've tryed to make the same but in the:
Private Sub GridControl1_DragOver(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles GridControl1.DragOver
    ' If e.Data.GetDataPresent(GetType(GridHitInfo))

allways returns False, so never enters the IF.

Added By: softwaresupport@smec.com softwaresupport@smec.com at: 6/4/2014 5:43:37 AM    

Hi created a new ticket for this implementation as i dont find that it works

Added By: softwaresupport@smec.com softwaresupport@smec.com at: 6/4/2014 5:44:03 AM    

Here is the ticket ID : T114366

Added By: Nikita (DevExpress Support) at: 6/4/2014 11:29:33 PM    

Hello,
Ok, let's continue our discussion in this ticket.

Added By: Miles Young at: 2/6/2015 7:34:33 AM    

Hi,

This works fine for me after I changed my "Order" column to decimal in my database.

I'd like to know how to change this value and make sure that RowUpdated() is fired though, like when I edit a row normally.

Thanks for this example.

M.Young

Added By: Svetlana (DevExpress Support) at: 2/6/2015 9:25:03 AM    Hi, 

We are already working on your inquiry in the How to force row update thread you created. We will answer you there. Please do not create duplicate posts. Thank you for your understanding. Added By: Dharmesh Jajal 1 at: 10/1/2015 3:53:16 PM    

Please post a solution if the datasource is not a datatable or dataset and is List<SomeRecord>.

Added By: Alisher (DevExpress Support) at: 10/2/2015 12:41:39 AM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T296044: Please post a solution if the datasource is not a datatable or dataset and is List<SomeRecord>. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

How to search through a specific column

PictureEdit - How to highlight and mark nested figures shown within an image

$
0
0
Imagine that your image shows a set of different figures like a diagram and you need to highlight a figure located under the mouse position or mark it with a predefined color by clicking it in the currently shown image. This example illustrates how to do this. The key point here is to specify rectangles associated with these nested figures and pass them to a custom PictureEdit, so that it can recognize them. Do this by using the CustomPictureEdit.NestedFigures collection. To specify your own colors used for highlighting the figures, use the CustomPictureEdit.Properties.HighlightFigureColor and CustomPictureEdit.Properties.ActiveFigureColor properties. 

ASPxGridView - How to select group rows in batch edit mode with the Select All ASPxCheckBox

$
0
0

This example shows how to add "Select All" ASPxCheckBox to select all rows, which are visible on ASPxGridView's current page, within some groups. 

After checking the "Select All" ASPxCheckBox, the group items, which are visible within ASPxGridView's current page, will change its checked state. Otherwise, this checking has no effect on the invisible items within its group.

The "Select All" ASPxCheckBox, which are placed inside ASPxGridView.Templates.GroupRowContent, change its ASPxCheckBox.CheckState according to the checked states of the items within its group. 

How to programmatically bind a report to an MDB file using a CustomSqlQuery

$
0
0

This example demonstrates how to create a new blank report (an instance of the XtraReport class), bind it to an MDB file, and fill the report's DetailBand with an XRLabel control displaying data from this file. 

Create a SqlDataSource class instance with the required connection parameters and construct a custom SQL query using the CustomSqlQuery class. To assign the created data source to the report, use the report's DataSource and DataMember properties.

Starting with v.17.2, the report uses expression bindings to provide data to controls. You can switch to the legacy binding mode by setting the UserDesignerOptions.DataBindingMode property to Bindings at the application startup.

See Also

How to programmatically bind a report to an MDB file using a SelectQuery

Question Comments

Added By: bmosbarg at: 9/24/2013 2:23:57 PM    

When I switch this connection to SQL Server 2005 the report is blank, no records appear. Do you have an example with SQL Server?

How to programmatically bind a report to an MDB file using a SelectQuery

$
0
0

This example demonstrates how to create a new blank report (an instance of the XtraReport class), bind it to an MDB file, and then, fill the report with a DetailBand containing XRLabels to show obtained data. 

To bind the report to an MDB file, create a SqlDataSource class instance with the required connection parameters. Then, create a SelectQuery to select columns from two data tables using an inner join relation as well as apply sorting, grouping, filtering and aggregation to data. To assign the created data source to the report, use the report's DataSource and DataMember properties.

Starting with v.17.2, the report uses expression bindings to provide data to controls. You can switch to the legacy binding mode by setting the UserDesignerOptions.DataBindingMode property to Bindings at the application startup.

See Also

How to programmatically bind a report to an MDB file using a CustomSqlQuery 

How to customize the appointment appearance


RichEdit - How to insert a table based on a DataTable object

$
0
0

This example demonstrates two possible approaches that allow you to insert a table inside the RichEdit document content based on data of a DataTable object.

The first approach adds a custom "DOCVARIABLE" field to the document content on the client side, fills it with a required table in the server-side event handler, and removes this field after inserting the table on the client side. The table is inserted into the document by using the RichEditDocumentServer component - our non-visual document processing engine. See the Table API - How to display a DataTable example for more information.

The second approach initiates an AJAX request to get the table data in the JSON format on the client side. Then, the required table is created and filled with data on the client by using the RichEdit client-side API.

See also:
ASPxRichEdit - How to insert a table based on a DataTable object

ASPxRichEdit - How to insert a table based on a DataTable object

$
0
0
This example demonstrates two possible approaches that allow you to insert a table inside the ASPxRichEdit document content based on data of a DataTable object.

The first approach adds a custom "DOCVARIABLE" field to the document content on the client side, fills it with a required table in the server-side event handler, and removes this field after inserting the table on the client side. The table is inserted into the document by using the RichEditDocumentServer component - our non-visual document processing engine. See the Table API - How to display a DataTable example for more information.

The second approach initiates an AJAX request to get the table data in the JSON format on the client side. Then, the required table is created and filled with data on the client by using the ASPxRichEdit client-side API.

See also:
RichEdit - How to insert a table based on a DataTable object

How to modify the default checking nodes behavior in the TreeList control

$
0
0

This example demonstrates how to modify the default checking nodes behavior in the TreeList control. The main idea is to handle the TreeList.BeforeCheckNode event, which occurs before a node's check state is changed.

The TreeListCheckHelper class allows the following scenarios:
- If a parent node has changed its check state, each child node will have the same state; 
- If at least one child node is checked, the parent node will be also checked.  

How to customize time scales in the Timeline view

$
0
0
This example demonstrates how to specify time scales for the Timeline View using the MVVM architectural pattern. 
The TimelineView.TimeScalesSource property allows you to bind the Timeline View to a collection of objects containing time scale settings described in the ViewModel. The Timeline View generates time scales based on templates. A template that describes time scales should be assigned to the view's TimelineView.TimeScaleTemplate property. This example uses the TimelineView.TimeScaleTemplateSelector property to choose the required template based on the time scale type. Three time scales are generated: Work Day, Work Hour and Half Hour.
The TimelineView.TimeScales collection stores all time scales of the current Timeline View. You can also use the collection's members to add, modify or remove time scales. 

How to add multiple time rulers to the Scheduler and adjust their settings

$
0
0

This example demonstrates how to add multiple time rulers to the Day View using the MVVM architectural pattern. 
The DayViewBase.TimeRulersSource property allows you to bind a scheduler view to a collection of objects containing time ruler settings described in the ViewModel. The DayViewBase.TimeRulerTemplate property specifies a data template based on which time rulers are generated.
Create a custom style for the TimeRulerCellControl to specify format strings for displaying time in the time rulers' time scale. 
The DayViewBase.TimeRulers collection stores all time rulers for the current view. You can also use the collection's members to add, modify or remove time rulers.

How to: Bind a Report to an Excel Workbook at runtime

$
0
0

This code example demonstrates how to create a new blank report at runtime (an instance of the XtraReport class), bind it to a Microsoft Excel workbook, and then, fill the report with a DetailBand containing an XRLabel to show data from this workbook.

To bind a report to an Excel data source, create a new instance of the ExcelDataSource class and specify the full path to the source Excel file using the FileName property. Then, specify required settings used to extract data from the workbook and manually define the data source schema. Finally, assign the created data source to the report using the DataSource property.

In this example, an XRLabel is added to the report to display data of one data field.

Starting with v.17.2, the report uses expression bindings to provide data to controls. You can switch to the legacy binding mode by setting the UserDesignerOptions.DataBindingMode property to Bindings at the application startup.

How to: Bind a Report to a CSV file at runtime

$
0
0

This code example demonstrates how to create a new blank report at runtime (an instance of the XtraReport class), bind it to data obtained from a CSV file, and then, fill the report with a DetailBand containing an XRLabel to show data from this file.

To bind a report to a CSV file, create a new instance of the ExcelDataSource class and specify the full path to the source file using the FileName property. Then, specify required settings used to extract data from the file and manually define the data source schema. Finally, assign the created data source to the report using the DataSource property.

In this example, an XRLabel is added to the report to display data of one data field.

Starting with v.17.2, the report uses expression bindings to provide data to controls. You can switch to the legacy binding mode by setting the UserDesignerOptions.DataBindingMode property to Bindings at the application startup.


ASPxGridView - How to implement search in the Column Chooser window

$
0
0

This example illustrates how to add an input element to the Column Chooser window and filter columns in this window.
First of all, create an input element and append it to the Column Chooser dom elements:

[JavaScript]
var _createElement = function(tag, parent){var element = document.createElement(tag);if(parent) parent.appendChild(element);return element;} that.appendToDom = function(){var tr = _createElement("tr"); tr.id = containerID;var td = _createElement("td", tr);var inputContainer = _createElement("div", td); inputContainer.id = extensionID;var inputElement = _createElement("input", inputContainer); inputElement.type = "text"; inputElement.onchange = that.onchange; inputElement.value = that.lastValue;if(inputElement.value) inputElement.onchange();var parent = that._getTable(); parent.insertBefore(tr, parent.children[0]);}

Note, that to correctly append the input element to the Column Chooser window, handle the client-side Init and EndCallback events and add the input element there.
After that, handle the onchange event and search for a typed value through the html table that contains field names:

[JavaScript]
that.onchange = function(){var newText = this.value.toLowerCase();var children = that._getTable().children;for(var i = 0, l = children.length; i < l; i++){var _tr = children[i];if(_tr.id == containerID)continue; _tr.classList.remove(hideClass);var _tds = []; _findChildren(_tr.children, "td", _tds)var hasText = _tds.filter(function(item){return item.textContent.toLowerCase().indexOf(newText)> -1}).length > 0;if(!hasText) _tr.classList.add(hideClass);} that.lastValue = newText;}

It is possible to hide a row with a field name that doesn't contain the typed text by setting a certain CSS class to the row element:

[CSS]
tr.cw-hide{display:none;}

How to add the search capability to the detail grid

$
0
0

This example demonstrates how to add the search capability to the detail grid.
Our detail grid with DataControlDetailDescriptor doesn't support search in the detail grid. To provide this capability in this sample, it's necessary to subscribe to the MasterRowExpanded event. After that, in the MasterRowExpanded event handler, set the detail TableView's ShowSearchPanelMode property to Never and bind the detail grid's SearchString to the master grid's SearchString.

Blog Web Site (WebForms project template from DevExpress Template Gallery)

$
0
0
This website is based on the Blog Web Site project template available in the DevExpress Template Gallery. This template utilizes DevExpress ASP.NET AJAX controls in conjunction with the Bootstrap framework to create a website with multi-page design and responsive, mobile-friendly interface out of the box. By default, the website has a format of a blog with integrated full-text search - see search.aspx page.

If you are using a custom Bootstrap theme, it is recommended that you manually modify the base color in the DevExpress theme of your choice to better suit the overall color scheme. You can accomplish this task by changing Theme Base Color.

==
See also (MVC version): Blog Web Site (MVC project template from DevExpress Template Gallery)

ASPxDropDownEdit (Extended Lookup) - How to use ASPxTreeList control inside the DropDownWindowTemplate

$
0
0

The ASPxTreeList control is placed into the ASPxDropDownEdit's dropdown window template, and a click on a node within the treeList changes the editor's value. A specific client API exposed by the ASPxDropDownEdit is used in this demo to assign a value to the editor (the SetText method), and manipulate the editor's dropdown window (the HideDropDown and AdjustDropDownWindow methods).

Question Comments

Added By: SALİH KAMALI at: 12/28/2017 6:01:30 AM    Hello.
How can I fired selectedIndexChanged event when the dropdownedit's selected item changes? We need to use this event in code behind.

Thanks.

How to provide any text for the RowIndicator

$
0
0

To provide custom content for the RowIndicator, declare a custom template by using the RowIndicatorContentTemplate property.

Question Comments

Added By: acQuire at: 5/29/2012 6:21:16 PM    

This no longer works in 2010.2 as the schema location has changed.

You need to add
xmlns:dxt="http://schemas.devexpress.com/winfx/2008/xaml/grid/themekeys"

and replace any dxg:RowIndicatorThemeKey in the xaml with dxt:RowIndicatorThemeKey

Also add IsThemeIndependant=True if you aren't using their themes.
<DataTemplate x:Key="{dxt:RowIndicatorThemeKey ResourceKey=IconPresenterTemplate, IsThemeIndependent=true}">

Viewing all 7205 articles
Browse latest View live


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