This example is obsolete.
In newer versions, use the built-in UserCellPadding property.
For older versions:
This example demonstrates how to create a custom GridView with the CellPadding property to specify paddings for its cells
How to implement paddings for the GridView cells
How to change colors of a highlighted text corresponding to a search string of Find Panel
The simplest way to change these colors is to modify the corresponding skin properties:
[C#]varskin=CommonSkins.GetSkin(LookAndFeel);skin.Colors[CommonColors.HighlightSearch]=Color.Red;skin.Colors[CommonColors.HighlightSearchText]=Color.Blue;
[VB.NET]Dim skin = CommonSkins.GetSkin(LookAndFeel) skin.Colors(CommonColors.HighlightSearch) = Color.Red skin.Colors(CommonColors.HighlightSearchText) = Color.Blue
If it's necessary to obtain these colors, use the following code:
[C#]ColorbackColor=skin.Colors.GetColor(CommonColors.HighlightSearch);ColorforeColor=skin.Colors.GetColor(CommonColors.HighlightSearchText);AppearanceDefaulthighlightAppearance=LookAndFeelHelper.GetHighlightSearchAppearance(LookAndFeel,true);
[VB.NET]Dim backColor As Color = skin.Colors.GetColor(CommonColors.HighlightSearch) Dim foreColor As Color = skin.Colors.GetColor(CommonColors.HighlightSearchText) Dim highlightAppearance As AppearanceDefault = LookAndFeelHelper.GetHighlightSearchAppearance(LookAndFeel, True)
Using this approach you can change colors of a highlighted text application wide. See the How to change one skin element in all available skins article for details.
Note, however, that we recommend that you create a custom skin using our Skin Editor tool. This approach is more stable since skin element names can be changed in future releases.
Alternatively, you can use custom painting to complete this task. This example illustrates how to customize foreground and background colors of a search string highlighted within located records in a grid using this approach. The main idea is to handle the CustomDrawCell event and use the ViewInfo.MatchedRanges property to paint the highlighted text.
Question Comments
Added By: anonimo at: 12/11/2013 2:17:30 PM
I need some similar but using memoEdit, how can I do It?
How to sort qualitative values in a custom order
How to display multiple summaries in the same column
Multiple total summaries are supported for a single column starting with version 11.1. To enable this feature, use the GridColumn.Summary property.
This example demonstrates how to display multiply summaries in the same column both in group and total footers.
Question Comments
Added By: Alejandro Cruzado 1 at: 5/17/2018 11:42:51 AM Hi,
Will the ability to display multiply summaries in the same column be available as a built-in feature in future versions?
Added By: Svetlana (DevExpress Support) at: 5/18/2018 5:44:25 AM
Hello,
I've created a separate ticket on your behalf (E2217: How to display multiple summaries in the same column). It has been placed in our processing queue and will be answered shortly.
How to customize an XPO business model at runtime (Example)
Sometimes there is a requirement to extend existing business classes when you cannot modify their source code.
For instance, you have an assembly where some persistent classes are declared. You want to use it in your XAF application and add attributes, new members, etc..
To use types from external assemblies, add them to the application as described in the Ways to Add a Business Class - Add Classes From a Business Class Library or Module article.
To see how to extend business classes at runtime, refer to the eXpressApp Framework > Concepts > Business Model Design > Types Info Subsystem > Use Metadata to Customize Business Classes Dynamically article.
This example demonstrates how to:
- Add an attribute to an existing class
- Create a new simple persistent property
- Create new reference and collection properties linked by an association
Important notes
1. By design you cannot dynamically add or remove the OptimisticLocking and DeferredDeletion attributes.
2. Adding custom members for Domain Components (DC) should be done on the XafApplication.SettingUp event as described at How do I define a custom member for a domain component (DC) at runtime?.
3. In XAF versions prior to 15.1.4, you cannot dynamically establish an association between two persistent classes via the XafTypesInfo API. Use the XPDictionary API instead.
See also:
How to: Access Business Class Metadata
Question Comments
Added By: Denis Sikic at: 11/15/2013 5:58:17 AM
Update the MyXPOClassLibrary project from Framework 3.0 to 4.0, in order to compile.
How to add custom Field Values (Rows/Columns) that are not present in a DataSource
As described in the Custom column/row values ( Show Field Values that are not present in the original data source ) ticket, PivotGridControl cannot display field values in row and column areas if these values are not represented in the underlying datasource. As a workaround you can add all required values to the original datasource or create a datasource wrapper that contains all required values on its level, and there is no need to modify original datasource.
This example illustrates how to create such a datasource wrapper. It is based on the How to create a data source wrapper that adds an empty item to the lookup list example.
To hide rows and columns with null field values, handle the CustomFieldValueCells event.
In the example, the CustomDates collection is filled with DateTime values based on the actual Start/End DateTime range and the specified interval (e.g., Month). This collection is passed to the DateDataSourceWrapper class instance along with the original data source collection (Table.DefaultView). The main idea of creating a custom wrapper class is to merge the CustomDates collection with the original data table without modifying the latter one. So, when PivotGridControl requests data using the common IList and ITypedList interface methods, wrapper returns data from the original collection or generates EmptyObjectPropertyDescriptor objects to return rows with null "Date" field values. For instance, check the DateDataSourceWrapper.this[int index] and DateDataSourceWrapper.GetItemProperties method implementations.
You can also check the following example that illustrates the ITypedList interface concept: How to: Implement the ITypedList Interface.
Question Comments
Added By: Pinaki Sen at: 5/26/2015 3:42:29 AM
How should we do it for a scenario wherein we need to pass on values for multiple fields?
Added By: John (DevExpress Support) at: 5/26/2015 11:31:31 PM Hi Pinaki,It seems that you have already asked this question in the Adding custom Field Values (Columns) that are not present in a DataSource topic. Let's continue the conversation there.
How to create a custom action type with a custom control (BarCheckItem), associated with it
This example demonstrates how to represent an action via the BarCheckItem. For this purpose, a SimpleAction descendant (CheckableSimpleAction) is implemented, because it is required to save the checked state of the action. To represent a custom action in a UI, the BarCheckItemCheckableSimpleActionControl is used. To bind an abstract action to its UI representation, a custom CheckableSimpleActionBinding is created. The binding operation is performed by CustomActionControlController.
Note that in most cases, it is not required to implement a custom action and action item. It is sufficient to customize the existing action item as described in the How to: Customize Controls Associated with an Action topic.
An example for ASP.NET is available here: How to create a custom action type with a custom control in Web
Question Comments
Added By: Alex Miller at: 6/19/2016 9:15:31 AM Is this still the same in 16.x? It seems BarActionItemsFactoryProvider.CreateBarActionItemsFactory() is never run.Added By: Alexey (DevExpress Support) at: 6/20/2016 3:18:58 AM
Hello,
I've created a separate ticket on your behalf (T394010: E1977 with version 16.1). It has been placed in our processing queue and will be answered shortly.
Thanks again!
How to prevent altering the legacy database schema when creating an XAF application
Scenario
This example shows how to keep the legacy database schema intact when creating an XAF application. Sometimes our customers want to connect their XAF applications to legacy databases, but they often have strong restrictions that disallow any changes in the legacy database schema, i.e. adding new tables, columns, etc. However, depending on the configuration, XAF may need to create additional tables. If the XafApplication.CheckCompatibilityType property is set to CheckCompatibilityType.ModuleInfo, the ModuleInfo table is used to track module versions. If you are using the Security System, additional tables are created to store users, roles, and permissions. XPO itself can add the XPObjectType table to correctly manage table hierarchies when one persistent object inherits another. Usually, legacy databases contain plain tables that can be mapped to one persistent object. So, the XPObjectType table is not necessary in such scenarios.
In this example, we customize the data storage mechanism to store the ModuleInfo and XPObjectType tables in a temporary database.
For this task we introduced a custom IDataStore implementation, which works as a proxy. This proxy receives all the requests from the application's Session objects to a data store, and redirects them to actual XPO data store objects based upon a table name that has been passed.
Steps to implement
1. In YourSolutionName.Module project create a custom IDataStore implementation as shown in the WinWebSolution.Module\XpoDataStoreProxy.xx file;
2. In YourSolutionName.Module project create a custom IXpoDataStoreProvider implementation as shown in the WinWebSolution.Module\XpoDataStoreProxyProvider.xx file;
3. In YourSolutionName.Module project locate the ModuleBase descendant and modify it as shown in the WinWebSolution.Module\Module.xx file;
4. Define connection strings under the <connectionStrings> element in the configuration files of your WinForms and ASP.NET executable projects as shown in the WinWebSolution.Win\App.config and WinWebSolution.Win\Web.config files.
IMPORTANT NOTES
1. The approach shown here is intended for plain database tables (no inheritance between your persistent objects). If the classes you added violate this requirement, the exception will occur as expected, because it's impossible to perform a query between two different databases by default.
2. One of the limitations is that an object stored in one database cannot refer to an object stored in another database via a persistent property. Besides the fact that a criteria operator based on such a reference property cannot be evaluated, referenced objects are automatically loaded by XPO without involving the IDataStore.SelectData method. So, these queries cannot be redirected. As a solution, you can implement a non-persistent reference property and use the SessionThatPointsToAnotherDatabase.GetObjectByKey method to load a referenced object manually.
3. As an alternative to the demonstrated proxy solution you can consider solutions based on database server features. Create a view mapped to a table in another database as a Synonym. Then map a regular persistent class to this view (see How to: Map a Database View to a Persistent Class).
See also:
How to implement XPO data models connected to different databases within a single application
How to: Use both Entity Framework and XPO in a Single Application
Question Comments
Added By: David Crumb at: 6/30/2016 4:58:07 PM How can you control which part of the applications use the LegacyDatabaseConnectionString and the TempDatabaseConnectionString
For example, although the below code works, it STILL tries to create a Note table within the LegacyDatabase.
In my situation, my legacy database is READ ONLY. I want to pull data only from my Legacy Database. Everything else, I want it to go to the TempDatabase.
Any insight appreciated,
--Dave
Added By: Dennis (DevExpress Support) at: 7/1/2016 10:30:01 AM @Dave: This is controlled by the following code in the XpoDataStoreProxy class:
According to the example's implementation and description, it is correct that the Note table is created in the legacy database as per the screenshot above. It is possible that you forgot to remove the this.AdditionalExportedTypes.Add(typeof(DevExpress.Persistent.BaseImpl.Note)); line when using this example implementation in your real project.Added By: Genesis Supsup (QuickZ) at: 1/16/2017 8:30:20 AM[C#]privatestring[]tempDatabaseTables=newstring[]{"ModuleInfo","XPObjectType"};privateboolIsTempDatabaseTable(stringtableName){if(!string.IsNullOrEmpty(tableName)){foreach(stringcurrentTableNameintempDatabaseTables){if(tableName.EndsWith(currentTableName)){returntrue;}}}returnfalse;}
Based from the code above, will this also work:[C#]e.ObjectSpaceProvider=newXPObjectSpaceProvider(provider);
[C#]e.ObjectSpaceProvider=newSecuredObjectSpaceProvider(provider);
Will this cause trouble later?Added By: Dennis (DevExpress Support) at: 1/16/2017 9:09:43 AM @Genesis Supsup:
I've created a separate ticket on your behalf (T472501: E1150 and SecuredObjectSpaceProvider). It has been placed in our processing queue and will be answered shortly.
How to change a cell template based on custom logic
This sample illustrates how to change a cell template based on a condition using CellTemplateSelector.
To implement this approach, do the following:
1. Implement custom DataTemplates. Editors declared in these templates should follow our recommendations from this help topic: CellTemplate:
[XAML]<DataTemplatex:Key="booleanEditor"><dxe:CheckEditName="PART_Editor"/></DataTemplate><DataTemplatex:Key="buttonEditor"><dxe:ButtonEditName="PART_Editor"/></DataTemplate><DataTemplatex:Key="comboboxEditor"><dxe:ComboBoxEditName="PART_Editor".../></DataTemplate><DataTemplatex:Key="dateEditor"><dxe:DateEditName="PART_Editor"/></DataTemplate><DataTemplatex:Key="textEditor"><dxe:TextEditName="PART_Editor"/></DataTemplate>
2. Create a custom DataTemplateSelector descendant. This descendant should return templates according to your scenario requirements.
Note: Each GridControl cell contains an object of the EditGridCellData data type in its DataContext. This object's RowData.Row property contains your data item. You can use this property if your logic should take property values from data items into account:
[C#]publicclassEditorTemplateSelector:DataTemplateSelector{publicoverrideDataTemplateSelectTemplate(objectitem,DependencyObjectcontainer){GridCellDatadata=(GridCellData)item;vardataItem=data.RowData.RowasTestData;returnstring.IsNullOrEmpty(dataItem.Editor)?null:(DataTemplate)((FrameworkElement)container).FindResource(dataItem.Editor);}}
How to Create a Custom Column Chooser
This example shows how to create a custom standalone Column Chooser and display it within the Expander control.
In this example, we implemented a custom CustomColumnChooserControl control that can be placed on a form. For example:
[XAML]<Grid><Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinitionWidth="170"/></Grid.ColumnDefinitions><dxg:GridControlx:Name="grid"><dxg:GridControl.View><dxg:TableViewx:Name="tableView"/></dxg:GridControl.View></dxg:GridControl><local:CustomColumnChooserControlx:Name="columnChooser"Grid.Column="1"/></Grid>
To associate it with a grid, set the CustomColumnChooserControl's View property to the grid's View object and set the DataViewBase.ColumnChooserFactory property in the following manner:
columnChooser.View = view; view.ColumnChooserFactory = New CustomColumnChooser(columnChooser);
Multiple selection using checkbox (web style)
Important note.
Starting with version 13.2, GridView provides a built-in checkbox column for multiple row selection. So, to enable this type of multiple row selection in newer versions, it is sufficient to enable the GridViewOptionsSelection.MultiSelect option and then set the GridView.OptionsSelection.MultiSelectMode property to the GridMultiSelectMode.CheckBoxRowSelect value. Take a look at the How to use an unbound check box column to select grid rows example for sample code.
Starting with version 18.1, in multiple row selection mode, you can sync row selected states with a Boolean field in the bound data source. The selection binding mode ensures that row selection persists whenever you filter or group grid data. Refer to the Multiple Row Selection via Built-In Check Column and Selection Binding help article for more information.
If you still prefer the custom approach described below, please clarify why the built-in solution is not suitable for you. Just click here to submit a ticket to our Support Center.
For earlier versions:
This example demonstrates how to add a check column to allow web-style multiple row selection. End-users can select/deselect rows, group rows or select/deselect all rows by clicking the column header. Changing a check box value does not initiate row editing.
All code related to selection resides in the GridCheckMarksSelection helper class. So, to implement this functionality in your application, you can simply add this class to your project and then create a new GridCheckMarksSelection instance.
Please note if you use the AppearanceEvenRow and AppearanceOddRow styles, by default they have a higher priority than the RowStyle event used for the selection in this example. To avoid drawing incorrect selected rows, enable the e.HighPriority option.
The GridCheckMarksSelection class also provides different ~Select methods which allow selecting data and group rows in code. To obtain selected rows, you can use the SelectedCount property and GetSelectedRow method.
Question Comments
Added By: Marc Roussel at: 10/11/2012 5:59:00 AM
Hmmm how do I use this class ?
Added By: You Logic at: 10/16/2012 4:16:54 AMWhen I select a row via code, the check box is not checked. How can I do this!?
Added By: Piotr Christ at: 2/8/2013 4:13:11 AMI had the same problem as You Logic ! How select row (with checkbox) from code ?
Added By: (no info) at: 11/25/2013 2:23:24 PMWhile this is a very nice implementation there is a problem with the code. Because you have defined selection *in the CheckMarkSelection.cs" as an ArrayList it is next to impossible to get at any values contained within each of the actual selected rows from the grid. Let's say one needs to obtain two of the values within the row...one is a string and one is an integer...how do you get the values out? There are no extension methods associated with "selection" that would allow you to enumerate the data lets say using linq or even simply doing somethin like: DataRowView theRow = (DataRowView)this.selection.GetSelectedRow(i); What happens is there is a cast error that occurs due to the generic types within the ArrayList. Granted this is necessary as we have an unknown group of column objects and values. There needs to be a built in method to access the individual values in the selected rows from "selection". I have tried 12 different methods to extract them and still a Cast error occurs.
Added By: Dave Smith 6 at: 3/4/2016 2:15:24 AM After implementing this class the column does not show, not sure what I'm doing wrong.In the constructor of my form I call new GridCheckMarksSelection(gridViewSearchInventory);
and then in the form load i bind to my grid Added By: Sasha (DevExpress Support) at: 3/4/2016 6:20:43 AM
Hello Dave,
I've created a separate ticket on your behalf: GridControl - The check box column is not shown when using a class from the E1271: Multiple selection using checkbox (web style) example .
We will update it shortly.
How can I modify View_Click() to invert group row selection when clicking the group checkbox ONLY?
Current implementation inverts selection when clicking anywhere in the group row.
Thank you Added By: Alisher (DevExpress Support) at: 4/14/2016 5:05:29 AM
Hello,
I've created a separate ticket on your behalf (T367815: How to invert group row selection when clicking the group checkbox only?). It has been placed in our processing queue and will be answered shortly.
How could I modify this sample so the check column is the very first column when AlignGroup SummaryInGroupRow = True?
I think this is related, but it's still confusing for me: https://www.devexpress.com/support/center/Question/Details/T365937#comment-e1c23ee5-92fd-4fd3-a2e3-b487a566d095
Thank you Added By: Alisher (DevExpress Support) at: 4/25/2016 5:18:54 AM
Hi Jacobo,
The AlignGroupSummaryInGroupRow option is available starting with version 15.2 of our components. Therefore I think that you are using the latest version of our products in your project. However, the functionality implemented in this example can be used out of the box in the mentioned version. Set the GridView's OptionsSelection.MultiSelect property to True and the OptionsSelection.MultiSelectMode property to CheckBoxRowSelect to enable it.
Would you please clarify why you are still using this example to achieve this functionality?
As for the issue with incorrect painting of column headers, we are aware of it and have already fixed it. Please take a look at the The Grid doesn't paint correctly either the column header or the cell value if AlignGroupSummaryInGroupRow is set ticket for more information.
Yes I'm in the latest version of your components, and I'm aware of the CheckboxRowSelect option.
However my original issue is the one described in : https://www.devexpress.com/Support/Center/Question/Details/T294110
(selection checkboxes are cleared when the grid is filtered). The solution to that issue sug gests to use the sample shown in this page to achieve checkbox column+filtering persistence so here I am.
My issue now is that when enabling AlignGroupSummaryInGroupRow the checkbox is shown after the grouped columns and I'd like to show it before. I did read the issue: https://www.devexpress.com/support/center/Question/Details/T365937
but it still unclear to me how can I proceed. Can you give some guidance?
thank you
Added By: Alisher (DevExpress Support) at: 4/26/2016 5:40:29 AM
Hi Jacobo,
Thank you for the clarification.
At present setting the AlignGroupSummaryInGroupRow property forces the Grid to display fixed columns after grouped columns. I don't see an easy way to overcome this behavior. I have created a separate ticket (GridControl - Setting the AlignGroupSummaryInGroupRow forces the Grid to display fixed columns after grouped columns) and passed it to our developers. We will examine the possibility of placing fixed columns before grouped columns. Please add that ticket to your Favorites to be notified of our progress.
when the form set on right to left , the checkbox not appears on group row Added By: Svetlana (DevExpress Support) at: 11/2/2018 6:12:50 AM
Hello,
I've created a separate ticket on your behalf (T687254: How to enabled the Right-to-Left mode in the E1271 example ). It has been placed in our processing queue and will be answered shortly.
How to use an unbound check box column to select grid rows
Starting with version 13.2, GridView provides a built-in checkbox column for multiple row selection. To enable this type of multiple row selection in newer versions, it is sufficient to enable the GridViewOptionsSelection.MultiSelect option and then set the GridView.OptionsSelection.MultiSelectMode property to the GridMultiSelectMode.CheckBoxRowSelect value.
Starting with version 18.1, in multiple row selection mode, you can sync row selected states with a Boolean field in the bound data source. The selection binding mode ensures that row selection persists whenever you filter or group grid data. Refer to the Multiple Row Selection via Built-In Check Column and Selection Binding help article for more information.
If you still prefer the custom approach described below, please clarify why the built-in solution is not suitable for you. Just click here to submit a ticket to our Support Center.
If you are using an earlier version of DevExpress controls, refer to the Multiple selection using checkbox (web style) example which demonstrates a method to manually create a check column for row selection.
Question Comments
Added By: Marco Villasesr at: 2/2/2014 8:31:14 AM
Could you please attach a sample Project, please? thank you!!
Added By: david ola at: 12/17/2015 5:18:30 AMHow do you respond to the selection change event? I needed to populate another grid based on the number of rows selected in my gridcontrol. Everything works well until no rows were selected. At that time, the SelectionChange event did not work. The other grid should be cleared when selectionCount become zero in my original gridcontrol, but it still displays the contents as if SelectionCount =1.
Is that a bug?
Hello,
Before I suggest a solution, I need to know which approach you use. Do you utilize the GridCheckMarksSelection helper class or the CheckBoxRowSelect select mode?
I look forward to hearing from you.
Added By: Zvi Goldenberg at: 8/22/2016 3:51:22 AM Hello.I need this functionality per column not per gridView.
Is it supported?
Thanks Added By: Dimitros (DevExpress Support) at: 8/22/2016 4:04:37 AM
Hello,
I've created a separate ticket on your behalf (T417641: How to create multiple checkbox columns in GridView?). It has been placed in our processing queue and will be answered shortly.
How to merge cells horizontally in GridView
Officially, GridControl doesn't support horizontal cell merging. We recommend using Spreadsheet, which supports cell merging:
How to: Merge Cells or Split Merged Cells
If you still prefer the custom approach described below, please clarify why the built-in solution is not suitable for you. Just click here to submit a ticket to our Support Center.
If it's necessary for you to have this functionality in GridControl, you can use this example, which demonstrates how to merge cells located in the same row.
The main idea is to paint merged cell manually. You can find a helper class in this example, which can be easily connected to your existing GridView.
Question Comments
Added By: John Nyari at: 9/16/2013 9:57:18 AM
Hi - all leads for horizontal merging seem to lead here. I have integrated it and found it works very well. However I seem to get a crash if the cells its merging are cells that have already been merged vertically. I am running v2012 12.2.8. Thanks
Added By: Maxim (DevExpress Support) at: 9/16/2013 11:32:16 PMHello John,
I have opened a separate issue on your behalf:
Application crash when using an approach from the E2472 example and merging cells horizontally
Please refer to this report for further correspondence on this item.
Added By: Chris Janssen 1 at: 12/18/2013 12:17:48 PMIt also crashes if you merge cells cells that have different types of data in them (merge a cell with an integer and a cell with a string)
Added By: Chris Janssen 1 at: 12/18/2013 12:30:39 PMAfter more testing It seems to crash because of an infinite loop.
If _view.GetRowCellValue(rowHandle, column) isNot value Then
_view.SetRowCellValue(rowHandle, column, value)
End If
The above code doesn't work when comparing integers, it always says they're different, so it keeps changing the value and getting called infinitely. When changed to
If _view.GetRowCellValue(rowHandle, column) <> value Then
_view.SetRowCellValue(rowHandle, column, value)
End If
it works.
Added By: HansG at: 1/2/2014 9:30:55 AMI think there is an error in addMergedCell:
The desired value of the cell is not put in the mergedCell list. This is, because the AddMergedCell with the integers as parameters does not use the AddMergedCell variant with "value".
To fix this add parameter "value" to the call of AddMergedCell in MyCellMergeHelpler.cs.
This will also fix the view of the strings, that where defined in Form1().
Alternativly don ́t use .absoluteIndex and just use the columns.
Added By: Dan Nordin at: 10/6/2014 7:12:40 PMHi, thanks for this example. The only problem I have with it is when you convert your grid over OptionsView.AutoColumnWidth = false and then scroll over so that one of the merged columns starts to disappear off the left side of the grid, it ends up covering up the Indicator column. Likewise if you scroll so the columns start to disappear off the right they end up covering about 1 pixel of the frame of the grid on the right side of the scrollbar (the far side of it). If this could be remedied in the example that would be a huge help to me because I need to implement this in a big grid with lots of scrolling. Thanks.
Added By: Demetrius (DevExpress Support) at: 10/7/2014 2:49:26 AMHi Dan,
I need to clarify some details to process your recent post more efficiently. I have created a separate ticket on your behalf: E2472 - Merged cells disappear while scrolling. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.
Added By: Philipp G at: 6/10/2015 2:31:14 AMHi, is there a way to also always display an Editor in the merged cell? (We would like to always display a RepositoryItemButtonEdit in one of the merged cells)
Added By: André (DevExpress Support) at: 6/10/2015 4:52:22 AMHello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T253679: How to display RepositoryItemButtonEdit in one of the merged cells. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.
I found I had to make these three changes to get it working correctly:
In the MyGridPainter.DrawMergedCell() add a check for a null ViewInfo before getting the bounds
if (gridCellInfo1.ViewInfo == null)//// this sometimes has a null ViewInfo for some reason.
return;
The AddMergedCell overload that took ints for the columns was missing the call to set the value.
public void AddMergedCell(int rowHandle, int col1, int col2, object value)
{
MyMergedCell cell = AddMergedCell(rowHandle, _view.Columns[col1], _view.Columns[col2]);
SafeSetMergedCellValue(cell, value);
}
The SafeSetCellValue needed to unbox the values before doing the compare.
public void SafeSetCellValue(int rowHandle, GridColumn column, object value)
{
if (_view.GetRowCellValue(rowHandle, column).ToString() != value.ToString())
_view.SetRowCellValue(rowHandle, column, value);
}
How to make the TreeList control look like a TreeView
The TreeList control provides support for a TreeView visual style, in which the control mimics the appearance of the .NET standard TreeView control. Starting from version 17.2, the TreeView visual style can be enabled using the single setting - ViewStyle.
In versions prior to 17.2, you can emulate the TreeView visual style as follows
- Hide column headers (set OptionsView.ShowColumns to False).
- Hide the indicator panel (set OptionsView.ShowIndicator to False).
- Hide the horizontal and vertical lines between cells (set OptionsView.ShowHorzLines and OptionsView.ShowVertLines to False).
How to enable the auto height feature for the column header panel
In version 14.1, we have added the GridView.OptionsView.ColumnHeaderAutoHeight property .
If you still prefer the custom approach described below, please clarify why the built-in solution is not suitable for you. Just click here to submit a ticket to our Support Center.
For older versions:
This example demonstrates how to introduce a capability to adjust the column header panel's height, based upon the column header contents.
Question Comments
Added By: Eddy Maldonado at: 7/11/2013 8:32:19 AM
Hi, it works perfect to me, but i need center the headers, when i activate the AppearanceHeader.TextOptions.HAlignment = Center its stop to work and headers don't fit anymore. Do you have an idea to center headers ? Best Regards.
Added By: Nathan Keir at: 10/24/2013 9:19:08 PMTo get this to work correctly I also needed to set Appearance.HeaderPanel.TextOptions.WordWrap = Wrap and Appearance.HeaderPanel.TextOptions.Trimming = EllipsisCharacter.
Added By: Richard Oberholz 1 at: 4/4/2014 9:43:57 AMInclude the code for the AutoHeightHelper class needed to make this code example work. I finally found that code at stackoverflow.com.
How to create a custom XtraMessageBox with the extended functionality
THIS EXAMPLE IS OBSOLETE SINCE THE REQUIRED FUNCTIONALITY IS SUPPORTED OUT OF THE BOX.
Starting with version 15.2, we implemented the XtraMessageBoxArgs.Showing event that is designed to customize the dialog form before it is shown. This allows you to disable/enable buttons, specify the form's start position etc.
Also, in version 18.1, we introduced the Auto Close feature for the XtraMessageBox dialog. Use the XtraMessageBoxArgs.AutoCloseOptions to customize it.
FOR EARLIER VERSIONS:
This example demonstrates how to create a MessageBox with an extended functionality. For this, create MyXtraMessageBox class descendant that is inherited from the XtraMessageBox class and uses the XtraMessageBoxArgs class - a MyXtraMessageArgs descendant which contains properties to customize the XtraMessageBox behavior.
If the built-in functionality does not suit you, we will be happy to find the most appropriate solution for you if you describe your real-life scenario. Just click here to submit a ticket to our Support Center.
Question Comments
Added By: Rainer Leonardy at: 7/9/2015 11:40:33 AM
if you run the project you will get an error "System.NullReferenceException"
you will get the error in the c# and the vb version
Public Shared Function GetDialogResultsFromButtons(ByVal buttons As MessageBoxButtons) As DialogResult()
Dim xtraMessageBoxInfo As MethodInfo = GetType(XtraMessageBox).GetMethod("MessageBoxButtonsToDialogResults", BindingFlags.Static Or BindingFlags.NonPublic)
error ---> Return DirectCast(xtraMessageBoxInfo.Invoke(Nothing, New Object() { buttons }), DialogResult())
End Function
Hello,
Thanks for your remark. This issue occurs because we have made certain changes in the XtraMessageBox class. Now, we updated this example so everything should work as expected.
Please check it.
Thank You - works fine
Added By: Antonio (DevExpress Support) at: 7/10/2015 3:16:04 AM Hi,I'm happy to hear that everything is OK.
How to implement an embedded Chart Control
Starting from version 17.2, the Chart Control can be directly embedded in a container control's cells using a RepositoryItemAnyControl object.
If the built-in functionality does not suit you, we will be happy to find the most appropriate solution for you if you describe your real-life scenario. Just click here to submit a ticket to our Support Center.
To embed a chart into a container control in previous versions, you need to manually create a custom chart control that implements the IAnyControlEdit interface. See the example below for more details.
See also:
RepositoryItemAnyControl Class
How to implement hot-track for grid rows during the drag-and-drop operation
Starting with v17.2, GridControl supports a Drag-and-Drop mechanism based on native Drag-Drop events (see: Drag-and-Drop). Now, it's sufficient to enable TableView's AllowDragDrop property to enable this functionality.
For versions prior to v17.2, you need to use Drag-and-Drop Managers for this purpose. Use this example's implementation from previous branches when you use such managers.
In this example, we illustrated how to highlight a target data row during the Drag-and-Drop operation. We implemented an attached HotTrackedRowHandle dependency property that stores a target data row's RowHandle value. We set this value to a corresponding value at the TableView level in the DragRecordOver event handler.
When the Drag-and-Drop operation is completed, we disable such highlighting by setting this attached property to GridControl.InvalidRowHandle in the CompleteRecordDragDrop event handler.
The appearance of the target row is determined by a custom RowStyle defined in the TableView. This style sets a row's background to a certain color if the value from the attached HotTrackedRowHandle property equals to this row's RowHandle value.
Please refer to the implementation of the HotTrackedRowStyle style and HotTrackBehavior attached behavior to see this.
See also:
Behaviors
How to: Create a Custom Behavior
Question Comments
Added By: Steve Durkee at: 9/24/2014 6:37:27 AM
This sample is blowing up after I converted it to 14.1.6
Added By: Ilya (DevExpress Support) at: 9/24/2014 9:57:59 AMHello Steve,
This is because Optimized Mode is used in 14.1 by default. In this mode, lightweight styles and templates are applied to grid rows. To resolve the issue, improve the HotTrackedRowStyle declaration as shown below:
[XAML]<Stylex:Key="HotTrackedRowStyle"TargetType="{x:Type dxg:RowControl}"><Style.Triggers> ... </Style.Triggers></Style>
We will improve the example for 14.1 in the near future.
How to access and remove rows by using a custom cell's context menu.
This example shows how to access and remove rows by using a custom context menu for cells.
To implement such a context menu, add corresponding BarItems to TableView's RowCellMenuCustomizations collection:
[XAML]<dxg:TableView.RowCellMenuCustomizations><dxb:BarButtonItemContent="Delete".../><dxb:BarButtonItemContent="Copy Cell Data".../></dxg:TableView.RowCellMenuCustomizations>
You can enable and disable such items based on property values in underlying data items. DataContexts in these items contain an object of the GridCellMenuInfo data type. This object's Row.Row property contains your data item instance. Therefore, you can bind to this data item's properties using the Row.Row.[Property_Name] path.
In this example, the Delete item is enabled only for rows whose CanBeDeleted property is True:
[XAML]<dxb:BarButtonItemName="deleteRowItem"Content="Delete"IsEnabled="{Binding Row.Row.CanBeDeleted}"ItemClick="deleteRowItem_ItemClick"/>
End-User Restrictions - How to implement a client-side confirmation on deleting an appointment
This example demonstrates how a delete appointment action can be confirmed using a client-side scripting technique. Note that the delete appointment action can be initiated from two places: a context menu and appointment form of ASPxScheduler.
For versions 14.2+
Use the ClientScheduler.MenuItemClicked event to override context menu behavior. For example, to display a confirmation window when an end-user deletes an appointment, handle this event as shown below:
[ASPx]<ClientSideEventsMenuItemClicked="OnMenuItemClicked"/>
[JavaScript]function OnMenuItemClicked(s, e){if(e.itemName == "DeleteAppointment"){ e.handled = !confirm('Are you sure that you want to delete this appointment?');}}
For versions prior to 16.2
To override context menu behavior, utilize the technique from the How to change default menu items and actions in the popup menu example. I.e., handle the ASPxScheduler.PopupMenuShowing Event and specify a custom client-side handler for the menu items via the e.Menu.ClientSideEvents.ItemClick parameter (see the code behind and markup of the "Default" webpage).
To override the "Delete" button behavior of the appointment form, you need to create a custom appointment form (see How to: Modify the Appointment Editing Form for Working with Custom Fields) and assign an appropriate client-side handler to the btnDelete.ClientSideEvents.Click property in the overridden DataBind() method of the form (see CustomAppointmentForm.ascx.cs code-behind file).
See Also:
How to implement a client-side confirmation on the user action modifying the appointment
Question Comments
Added By: Donald Lindstedt at: 6/8/2015 2:17:12 PM
aspxAppointmentDelete is obsolete in v15.1.3.
ASPx.AppointmentDelete is now required.
Hi,
Thank you for your reply!
I've modified this example so that it meets our latest version requirements.