In this video you’ll learn how to get started with the DevExpress Winforms Grid Control.
Locate the GridControl component in the DX: Data & Analytics tab on the Visual Studio
toolbox and drop it onto the form.
Let’s now use the grid to show data from an SQL Server database.
First, choose a Data Source type.
Select the “Database” and click Next to proceed.
In “Choose a Database Model” select “Dataset” and click Next.
Click the “New Connection” button to create a new Database connection.
By default, the Data Source type is set to Microsoft Access Database File.
Let’s click the “Change” button and choose a Microsoft SQL Server.
In the dialog that appears, choose a server name and a Database to connect to.
In this example we use the sample Adventure Works database file.
You can click “Test Connection” to check the connection.
And Finally, click the “Ok” button.
Now all you have to do is to choose a data table for the Grid to display.
Let’s select the “Employees” table.
Let’s uncheck the columns we won’t need and click the “Ok” button.
And that's it, lets run the application to see the result.
Now you can see that the Grid is ready to go with automatically generated columns and
populated data.
You get a fully functional Grid Control without writing a single line of code.
End users can arrange and resize columns as they desire.
To sort data against a column, click this column's header Click again to revert sorting
order (ascending to descending).
To apply a filter, click the filter button within the required column header.
Note that the filter panel at the bottom allows you to customize the filter criteria even
further.
Not only can you modify Grid Columns, but you can group Grid Data by specific columns.
To do so, drag the required column to the GridView's header.
Now all your data is grouped by this column, "Title" in our case.
End-users can also search for records containing required entries via the Find Panel.
To invoke this panel, press the Ctrl+F shortcut.
These are just a few of the data shaping capabilities provided by the DevExpress WinForms Grid.
Note that if you select the grid control, you can only access the settings that specify
the control’s positioning on the form and other generic control settings.
The grid displays data and enables end-user interaction via View objects – so you need
to select the View to customize how the grid looks and behaves.
Click the View to display its properties within the Properties window.
The GridView's main settings are grouped into several categories for your convenience.
For example, the OptionsFind section contains properties related to the Search Panel that
we can enable by default by toggling the corresponding option.
The OptionsBehavior section allows you to fine-tune various functionality aspects of
the grid.
To customize element visibility and layout, use the OptionsView section For example, set
the ColumnAutoWidth property to false to disable automatic column width adjustment to the View
width.
To customize specific column settings, select a column and modify the required properties
in the Properties window.
For example, you can anchor a column to the left or right edge, so it never moves while
scrolling through the Grid.
Yet another way to customize grid settings is via the Property Editor dialog.
To invoke the dialog click the corresponding link within the Grid Controls smart tag.
Let’s group our data by the Title column.
To add a summary item, invoke the Grid designer switch to the "Group Summary Items" tab and
click the "+" button.
Let's set the "Field Name" property to "Title".
Our data is grouped by this column, so leave the "ShowInGroupColumnFooter" property unchanged.
Finally, set the "Summary Type" property to "Count".
And lets run the application to see the result.
Each group now contains a summary item that displays the record count for each group.
You can use Smart Tags to access key properties of various grid elements – such as columns.
Let’s use this feature to specify in-place data editors for column cells.
Select a column, click the smart tag and locate the "Column Edit" property.
Here you can choose a previously used editor type or create a new one.
Let's click the "New" node and select the required item from the list..
Set a “TextEdit” editor for the HireDate column and then use the Properties window
to access editor settings.
You’ll see editor settings under the ColumnEdit property, where you can specify the edit mask
and display format for the recently assigned Text Editor.
Now lets use the Level Designer in the bottom-right corner of the grid to change the grid’s
data display format.
Convert the GridView to LayoutView This View type will display separate cards for each
record.
You can change the cards layout via corresponding buttons at the View's top - one card, multiple
cards, carousel etc.
Some GridControl's features are not View-specific and can be used in multiple or all Views.
For example, the Find Panel invoked via the Ctrl+F hotkey allows you to search for records
containing specific strings.
Now you’ve learned all the basic ways to customize the Grid Control.
Explore the level navigator, view and column settings and the Property Editor dialog to
find more settings.
Learn even more at the DevExpress Documentation Center at help.devexpress.com.
Thanks for watching and thank you for choosing DevExpress.