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

How to flatten an interactive form


How to disable a particular row in the GridView

$
0
0

This example demonstrates how to create a helper class that allows you to enable/disable rows with ease. A disabled row is a row that has a specific appearance, and its in-place editors can't be activated.

Question Comments

Added By: Anthony Rich at: 7/8/2013 7:01:19 PM    

This seems like a bug in RowStateHelper.cs:
public GridView GridView
{
     set { UnSubscribeEvents(value); _GridView = value; SubscribeEvents(value); }
}

Shouldn't it be this:
public GridView GridView
{
     set { UnSubscribeEvents(_GridView); _GridView = value; SubscribeEvents(value); }
}
private void UnSubscribeEvents(GridView view)
{
     if (view != null)
     {
          view.RowCellStyle -= view_RowCellStyle;
          view.ShowingEditor -= view_ShowingEditor;
     }
}

Added By: Mary Xin at: 10/31/2013 8:52:47 AM    

I have a grid and it's showing a list of invoices from the table. If the invoice has been posted then I want the row disabled so a user can't edit it.

I am using vb.net. Can you tell me the steps how to do it? I am new to this grid control.

Thanks

Added By: Dean Martin at: 3/6/2014 12:51:27 PM    

This does not handle the situation where rows above a disabled row are deleted. Say I disable rows 5 thru 10. I can delete the rows above row 5 (rows 1 thru 4). And as I do that, what were rows 5 thu 10 now scroll up and I can now edit them or even delete them.

Added By: Dimitros (DevExpress Support) at: 3/6/2014 11:15:04 PM    

Yes, you are right, this example doesn't handle this situation. In this example, we just show the main idea how to accomplish this task. To simplify our code, we use a row datasource index to identify rows. If you want to add/delete rows and save their disabled state, I suggest that you use a key field value to identify rows. In this case, this approach will work correctly.

Added By: Jerzy Rozmyslowicz at: 12/18/2016 11:23:13 AM    this example does not explain anything, just adding dataAdded By: Stas (DevExpress Support) at: 12/19/2016 12:41:50 AM    

Hello Jerzy,
The main idea of the approach demonstrated in this example is to store indices of data source rows in the DisabledRows list. Then handle the GridView.RowCellStyle event to assign an appearance object that stores the appearance settings to the e.Appearance parameter if the currently processed row resides in the DisabledRows list. To make a row that is stored in the DisabledRows list read only, you need to handle the ColumnView.ShowingEditor event and check if the currently focused row exists in the DisabledRows list. If so, set the e.Cancel parameter to true.
I hope this explanation is helpful. Should you have additional questions, let me know.

How to create a GridView descendant class and register it for design-time use

$
0
0

Starting with v16.1, you can create a custom GridView with all the required classes using our Template Gallery. Use the "Custom Data Grid" template.


This is an example of a custom GridView and a custom control that inherits the DevExpress.XtraGrid.GridControl. Make sure to build the project prior to opening Form1 in the designer. Please refer to the How to create a GridView descendant class and register it for design-time use Knowledge Base article for the additional information.
In addition, you can refer to the examples describing how to create GridControl's View descendants:
1. How to create a WinExplorerView descendant class and register it for design-time use
2. How to create a LayoutView descendant class and register it for design-time use
3. How to create a CardView descendant class and register it for design-time use
4. How to create a AdvBandedGridView descendant class and register it for design-time use ;
5. How to create a BandedGridView descendant class and register it for design-time use; 
6. How to create a TileView descendant class and register it for design-time use.

How to create a WinExplorerView descendant class and register it for design-time use

$
0
0

Starting with v16.1, you can create a custom WinExplorerView with all the required classes using our Template Gallery. Use the "Custom Data Grid" template.


This is an example of a custom WinExplorerView and a custom control that inherits the DevExpress.XtraGrid.GridControl. Make sure to build the project prior to opening Form1 in the designer.

To obtain general information about creating and registering a custom view descendant class at design time, refer to the following Knowledge Base article: How to create a GridView descendant class and register it for design-time use.

Question Comments

Added By: Daniel Kaminski at: 5/30/2015 10:15:48 AM    

Could you please make this example available in VS2010?
Thanks!

Added By: Andrew Ser (DevExpress Support) at: 6/1/2015 9:17:17 AM    Hello,
Thank you for the remark. We will update this example. As for now, you can open the csproj file, find the "TargetFrameworkVersion" node and change it to 4.0.

How to create a LayoutView descendant class and register it for design-time use

$
0
0

Starting with v16.1, you can create a custom LayoutView with all the required classes using our Template Gallery. Use the "Custom Data Grid" template.

This is an example of a custom LayoutView and a custom control that inherits the DevExpress.XtraGrid.GridControl. Make sure to build the project prior to opening Form1 in the designer.

To obtain general information about creating and registering a custom view descendant class at design time, refer to the following Knowledge Base article: How to create a GridView descendant class and register it for design-time use.

Question Comments

Added By: Don Fadely at: 10/6/2014 11:22:43 AM    

I need to see your designer code module for the form.  Since the control doesn't show up in the toolbox, I'll need to add it manually.

Added By: Yaroslav (DevExpress Support) at: 10/6/2014 1:21:29 PM    Hi Don,
To resolve the issue, add the ToolBoxItem attribute to classes you want to see in your toolbox. See the following code:
[C#]
[ToolboxItem(true)]publicclassMyGridControl:GridControl{}

How to create a CardView descendant class and register it for design-time use

$
0
0

Starting with v16.1, you can create a custom CardView with all the required classes using our Template Gallery. Use the "Custom Data Grid" template.

This is an example of a custom CardView and a custom control that inherits the DevExpress.XtraGrid.GridControl. Make sure to build the project prior to opening Form1 in the designer.

To obtain general information about creating and registering a custom view descendant class at design time, refer to the following Knowledge Base article: How to create a GridView descendant class and register it for design-time use.

How to create a AdvBandedGridView descendant class and register it for design-time use

$
0
0

Starting with v16.1, you can create a custom AdvBandedGridView with all the required classes using our Template Gallery. Use the "Custom Data Grid" template.

This is an example of a custom AdvBandedGridView and a custom control that inherits the DevExpress.XtraGrid.GridControl. Make sure to build the project prior to opening Form1 in the designer.

To obtain general information about creating and registering a custom view descendant class at design time, refer to the following Knowledge Base article: How to create a GridView descendant class and register it for design-time use.

How to create a BandedGridView descendant class and register it for design-time use

$
0
0

Starting with v16.1, you can create a custom BandedGridView with all the required classes using our Template Gallery. Use the "Custom Data Grid" template.

This is an example of a custom BandedGridView and a custom control that inherits the DevExpress.XtraGrid.GridControl. Make sure to build the project prior to opening Form1 in the designer.

To obtain general information about creating and registering a custom view descendant class at design time, refer to the following Knowledge Base article: How to create a GridView descendant class and register it for design-time use.


How to create a TileView descendant class and register it for design-time use

$
0
0

Starting with v16.1, you can create a custom TileView with all the required classes using our Template Gallery. Use the "Custom Data Grid" template.

This is an example of a custom TileView and a custom control that inherits the DevExpress.XtraGrid.GridControl. Make sure to build the project prior to opening Form1 in the designer.

To obtain general information about creating and registering a custom view descendant class at design time, refer to the following Knowledge Base article: How to create a GridView descendant class and register it for design-time use.

How to: Adjust the size of pop up dialogs

$
0
0

ASP.NET
A complete description for the  ASP.NET version is available in the How to: Adjust the Size of Pop up Dialogs displayed in ASP.NET Applications topic.


WinForms
Check out the PopupSizeExample.Module.Win\Controllers\CustomizeFormSizeController.xx file and code comments in it. See also the following product documentation:
    Concepts> Extend Functionality> Controllers
    DevExpress.ExpressApp> Frame> TemplateChanged
    DevExpress.ExpressApp> XafApplication> CustomizeTemplate
    DevExpress.ExpressApp.Templates> ISupportStoreSettings> SettingsReloaded

Take special note that certain form templates (e.g., LookupForm, PopupForm, LookupControlTemplate)  may have a minimum form size set by default (using the MinimumSize  property) or may calculate their size dynamically based on the content. So, if your custom size is ignored using the aforementioned method, you may want to research the source code for each required form template and adjust your default form settings accordingly.

Question Comments

Added By: Ari Vesteinsson at: 12/19/2016 5:33:15 AM    The Frame.TemplateChanged property is not static - this code will not compile as is. Is there additional code we're expected to include?Added By: Alexey (DevExpress Support) at: 12/19/2016 6:02:40 AM    

Hello,

I've created a separate ticket on your behalf (T464212: Frame.TemplateChanged property is not static ). It has been placed in our processing queue and will be answered shortly.

GridView - How to export filtered data with Reports when using the BindToLINQ method with large data

$
0
0

At present our MVCxGridView export mechanism has some limitations: it is impossible to export a lot of filtered data, because the mechanism requests all data from a database and then filters it. Thus, a request can be fulfilled, and the 'System.OutOfMemoryException' exception occurs. As a solution, request filtered data yourself and export it using the XtraReports Suite. This example demonstrates how you can do this using LINQ-to-SQL.

To pass the FilterExpression to a Controller's Action, obtain and save it to GridView CustomJSProperties in CustomJSProperties:


[C#]
settings.CustomJSProperties=(s,e)=>{ASPxGridViewgrid=(ASPxGridView)s;e.Properties["cpGridFilterExpression"]=grid.FilterExpression;};settings.CustomJSProperties=Sub(s,e)DimgridAsASPxGridView=DirectCast(s,ASPxGridView)e.Properties("cpGridFilterExpression")=grid.FilterExpressionEndSub

When a user clicks the Export data, take the filter expression from GridView CustomJSProperties and add it to the collection of jQuery selector parameters.

[JavaScript]
function OnClick(s, e){var actionParams = $("form").attr("action").split("?filterString="); actionParams[1] = gvDataBindingToLinq.cpGridFilterExpression; $("form").attr("action", actionParams.join("?filterString="));}

The XtraReport class instance that's used in this Code Example is added as described in the Lesson 1 - Create a Static Report in ASP.NET MVC tutorial. The report controls are bound to data using the Embedded Fields (Mail Merge) feature.

You can learn more about approaches used in this example in the following resources:

How to: Create a Table Report
How to create a web based report at runtime
How to convert the CriteriaOperator to a lambda expression, so, the latter expression can be used in the IQueriable source

GridView Extension - Provide the capability to export large LINQ data
Walkthrough: Installing the AdventureWorks Database

Question Comments

Added By: Kevin Turpin 1 at: 2/10/2016 11:50:47 AM    OK, i absolutely love that i can do this, nicely done.Added By: John John Smith at: 3/23/2016 9:39:34 AM    There really isn't any difference between binding to an XtraReport just to export, and using a datatable is there?  The code in the home controller looks almost identical.

It doesn't matter how I filter my data, if it goes above the .Net 2gb limit then it throw the out of memory exception error.Added By: Vladimir (DevExpress Support) at: 3/23/2016 12:59:31 PM    

Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T359906: The out of memory exception occurs when GridVIew data in being exported. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: Gustavo Paradiso at: 12/19/2016 3:22:05 PM    Hi,
i'm trying to apply this aproach with MVCExtensions. I filter my grid using SearchPanel and everytime the grid does the callback ((MVCxGridView)s).FilterExpression returns an empty string.

 settings.CustomJSProperties = (s, e) =>
    {
        MVCxGridView gr = (MVCxGridView)s;
        e.Properties["cpGridFilterExpression"] = gr.FilterExpression; // FilterExpression always returns ""
    };

Does it work for MVC? Added By: Nataly (DevExpress Support) at: 12/19/2016 10:22:57 PM    

Hello,

I've created a separate ticket on your behalf (T464479: GridView - How to export data filtered by Search Panel). It has been placed in our processing queue and will be answered shortly.

How to define a custom IConnectionStorageService in DashboardDesigner Wizard to filter out unnecessary connections from an app.config file  

$
0
0

This example demonstrates how to implement a custom IConnectionStorageService and use it instead of the default one in the data source wizard. This service implementation allows only getting connection parameters from the DashboardDesigner.CustomDataConnection collection. To load the custom service instead of the default one, execute the following code:

[C#]
dashboardDesigner1.ServiceContainer.RemoveService(typeof(IConnectionStorageService));dashboardDesigner1.ServiceContainer.AddService(typeof(IConnectionStorageService),newCustomConnectionStorageService(dashboardDesigner1));

Note that starting with version 15.2 the connection from the app.config are not used by default. To enable this functionality use the DashboardDesigner.DataSourceWizardSettings.ShowConnectionsFromAppConfig Property

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.

Question Comments

Added By: Jürgen Becker at: 12/20/2016 3:42:43 AM    Hi,

works like a charm. I like it.

Regards Jürgen

ASP.NET MVC Dashboard - How to use separate server-side settings for different views

$
0
0
This example shows how to use separate DashboardConfigurator instances within an ASP.NET MVC Dashboard application to provide different server-side settings. In this example, the Sales and Marketing views use different dashboard storage and different data connections.

Chart3D Getting Started Lesson 2, Step 1 Result


How to load and save a password encrypted file

How to open a password protected .xls file

$
0
0
Starting with version 16.2, this technique becomes obsolete. Refer to the How to load and save a password encrypted file example for more information.

This example demonstrates the technique required to open a password protected .xls file prompting user for a correct password. 
When the Spreadsheet control attempts to open a password protected .xls file and the Password property is not set, the control raises the InvalidFormatException event with the SpreadsheetDecryptionException exception in event arguments. If this event is not handled, the control cancels loading without any alert.
The method is to subscribe to the InvalidFormatException event, prompt the user for a password, specify the password and call the SpreadsheetControl.LoadDocument.
Note that this technique can be used for password-protected .xls documents created with Microsoft Excel versions up to 2010. The test file password123.xls is included in the project. Run the application and open this file using CTRL-O or the Open File... command. When prompted for a password, type in 123.

Grid for Xamarin - Columns

$
0
0
This example demonstrates how to add columns to GridControl to display and edit data of different types. Grid columns are stored in the GridControl.Columns collection. An individual column is specified by a GridColumn class descendant, which is appropriate to the type of data contained in this column. The following column types are available in the grid:
- ImageColumn
- TemplateColumn
- NumberColumn
- TextColumn
- DateColumn
- PickerColumn
- SwitchColumn
The complete description is available in the How to: Create Grid Columns for Data of Different Types topic.
Question Comments

Added By: Srinivas Vadla at: 12/20/2016 9:21:23 PM    Hi,
I need simple  example code for  grid with Xamrin.andriod project. I am unable to understand your example in devexpress.com
Added By: Alex Bli (DevExpress Support) at: 12/20/2016 10:58:32 PM    Hi,

Our controls are implemented only for Xamarin.Forms projects, and as a result, it is impossible to use them in Xamarin for Android projects and we cannot provide you with such an example.


Thanks
Alex

OBSOLETE - Image Upload in ASPxGridView

$
0
0

UPDATED:

Starting with version v2015 vol 1 (v15.1), this functionality is available out of the box. Simply set the GridViewDataBinaryImageColumn.PropertiesBinaryImage.EditingSettings.Enabled property to True to activate it. Please refer to the ASP.NET Data Grid - Binary Image Editor (Coming soon in v15.1) blog post and the Binary Image Column Editing demo for more information.

If you have version v15.1+ available, consider using the built-in functionality instead of the approach detailed below.

The ASPxUploadControl can be used within the ASPxGridView's Edit Form to upload image files to the grid's bound database. In the online sample, the grid's data is stored within the Session object and is obtained/modified by using the ObjectDataSource component.

The project version that employs a SqlDataSource component is also provided in a separate zip file within the example folder.

See also:
How to bind the ASPxBinaryImage to a field which contains image data stored as OLE object
OBSOLETE - Inserting a new row in ASPxGridView with the image preview enabled

Question Comments

Added By: zain ul arfeen at: 1/23/2014 12:09:12 AM    

It is a nice post... But i cannot understand where and how should i bee using the file.SaveAs to save the file at some place???

Added By: Mehul Harry (DevExpress) at: 1/23/2014 2:26:42 PM    

Zain, you can download this entire project and run it locally in your VS. To see the relevant source files online, just cclick the dropdown above the code which let's you select the files. If you still need help then please contact our support team here: http://www.devexpress.com/Support/Center/CreateIssue.aspx?issuetype=Question

Thanks.

Added By: Esther Hazan at: 11/22/2016 1:47:50 PM    I see that all the posts on this issue are marked obsolete. id there an example of adding a file upload in each row of a grid view that is current?Added By: Vladimir (DevExpress Support) at: 11/22/2016 11:01:50 PM    Currently, we recommend using GridViewDataBinaryImageColumn as mentioned in this example description. If it does not work for you, would you please submit a ticket and describe your scenario in detail?Added By: Ryan Manning at: 12/20/2016 4:04:38 PM    The recommendation of using GridViewDataBinaryImageColumn  assumes that people only want to upload images.  Assuming we'd still like to upload other binary types (PDF, etc.), what is the current recommended approach?Added By: Ryan Manning at: 12/20/2016 4:07:02 PM    Also, in this example, the only way to insert a record using the modified edit form is to complete an upload, thereby calling the grid.UpdateEdit() method.  Is there a way to insert the record if no file was uploaded?  Basically, what if the file upload is optional?Added By: Pavlo (DevExpress Support) at: 12/20/2016 11:22:43 PM    

Hello,

I've created a separate ticket on your behalf (T465036: How to implement E95 example with optional file upload). It has been placed in our processing queue and will be answered shortly.

ASP.NET - How to provide a Screen Reader with information about changes between linked controls

$
0
0

This example illustrates how to provide a custom message to an Assistive Technology (for example, Screen Reader). The main idea of this approach is to add a special helper element to the page, set your custom message as its "aria-label" attribute value, and then focus this element. This will force your screen reader or another assistive technology to read the message.


Here, the task is implemented for a basic ASP.NET ListBox and DevExtreme dxDataGrid widget. The grid displays data depending on the ListBox selection. When the selection is changed, the data in the linked grid is filtered  and we send a custom information message. A similar scenario is illustrated in the Accessibility - Linked Controls online demo, but instead of a custom AccessibilityHelper implementation, this demo uses our client API: ASPxClientUtils.SendMessageToAssistiveTechnology.

Main implementation steps:
1. Add a special assistive element to the page using the AccessibilityHelper constructor (its implementation is in the AccessibilityHelper.js file):

[JavaScript]
var accessibilityHelper = new AccessibilityHelper();

 2. Save the old state for a control or page, when necessary. In this example, the ListBox' onchange event is used for this purpose:

[JavaScript]
listBox.change(function(){... oldClientCount = grid.totalCount(); countriesChanged = true;...});

 You can handle several events for different controls in your real-life scenario.

3. Handle the event that occurs when changes are complete. Here, the dxDataGrid.onContentReady event is used. Check if there is the difference between the previous and current states, and to pass the corresponding message text as an argument to the AccessibilityHelper.SendMessageToAssistiveTechnology method:

[JavaScript]
function OnContentReady(){...var newCount = grid.totalCount();var changesInfo = GetChangesInfo(newCount); accessibilityHelper.SendMessageToAssistiveTechnology(changesInfo);}

 The complete implementation of the AccessibilityHelper.SendMessageToAssistiveTechnology method is in the AccessibilityHelper.js file.


To test the example, run it in browser and enable your assistive technology. You can use NVDA or JAWS screen readers for testing purposes. Change the "Countries" list box selection: the assistive software or device should inform you about the changes in the "Clients" grid with a corresponding message.

See Also:
Accessibility - How To: Provide a Screen Reader with Information About Changes on a Page

Viewing all 7205 articles
Browse latest View live


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