Access Grid Control Properties Grid access control properties

In this lesson, you will learn how to access the properties of a list form's Grid Control in WinForms and ASP.NET Web applications. For this purpose, new View Controllers will be implemented. They will set alternating row colors in all List Views represented by the built-in GridListEditor and ASPxGridListEditor.

In this lesson, you will learn how to access the property grid control List form in WinForms and ASP.NET Web applications. For this purpose, the controller will implement the new view. They all set alternating row colors represented by the list view and the grid editor ASPxGridListEditor built in.

Note Note

Before proceeding, take a moment to review the following lessons.

Before proceeding, please take a moment to review the following courses.

 

Add a Simple Action

simple operation of adding

Access Editor Settings in a WinForms Application

Access WinForms application settings editor

  • Since the functionality to be implemented is specific to the WinForms platform, changes will be made to the MySolution.Module.Win project. Add a View Controller to the Controllers folder in the MySolution.Module.Win project, as described in the Add a Simple Action lesson. Name it "WinAlternatingRowsController".
  • Invoke the Controller's Designer. In the Properties window, set the TargetViewType property to the "ListView" value. This is necessary because the Controller should appear in List Views only.

  • Since the WinForms platform-specific functionality to be realized, the project will therefore MySolution.module.Win change. Add the view controller to controller MySolution.module.Win project folder, such as "simple operation of adding" the lesson. It will be named "win Controller Controller."

  • Call controller designer. In the "Properties" window, the TargetViewType property to "the ListView" value. This is necessary because the controller should appear only in the list view.

    Tutorial_EF_Lesson10_3

  • Since you are going to access the settings of the List View's Grid Control, you need to ensure that it has already been created. This is why you need to subscribe to the Controller's ViewControlsCreated event. In the Properties window, switch to the Events view and double-click the ViewControlsCreated event. Handle the event as shown below.

  • Since you will want to set grid access control list view, so you need to make sure that the setting has been created. This is why you need to subscribe to the view control of the controller to create an event. In the "Properties" window, switch to the "Events" view and double-click on "View control to create" event. Event processing, as shown below.

    using System.Drawing;
    using DevExpress.ExpressApp.Win.Editors;
    using DevExpress.XtraGrid.Views.Grid;
    //... 
    private void WinAlternatingRowsController_ViewControlsCreated(object sender, EventArgs e) {
        GridListEditor listEditor = ((ListView)View).Editor as GridListEditor;
        if (listEditor != null) {
            GridView gridView = listEditor.GridView;
            gridView.OptionsView.EnableAppearanceOddRow = true;
            gridView.Appearance.OddRow.BackColor = Color.FromArgb(244, 244, 244);
        }
    }

     

    As you can see in the code above, to access a list form's Grid, you should first get the ListEditor, which is the object that binds data to a Grid. To get the ListEditor, use the ListView.Editor property of the required List View. There are several types of built-in WinForms ListEditors. The code above is implemented when the current List View is represented by a GridListEditor. This ListEditor represents data via the XtraGrid control. Use the GridListEditor.GridView property to access this control.

            If you shown in the above code, to access the list of the form of a grid, you should first get ListEditor, which is to bind data to grid object. To get a list editor, use the ListView desired list view. Editor Properties. There are several types of built-in WinForms List Editor. When a view showing a current listing GridListEditor,

            The code will be achieved. This list represents the data editor by XtraGrid control. Using the Grid Editor .GridView property access this control.

 

  • Run the WinForms application and select an item in the navigation control. The data rows now have alternating colors.

  • Run WinForms application and select an item in the navigation controls. Now the data row having alternating colors.

    Tutorial_EF_Lesson10_4

Access Editor Settings in an ASP.NET Application

Access ASP.NET application settings editor

  • As the functionality to be implemented is specific to the ASP.NET platform, changes will be made to MySolution.Module.Web in this lesson. Add a View Controller to the Controllers folder in the MySolution.Module.Web project, as described in the Add a Simple Action lesson. Name it "WebAlternatingRowsController".
  • Invoke the Controller's Designer. In the Properties window, set the TargetViewType property to the "ListView" value. This is necessary because the Controller should appear in List Views only.

  • 由于要实现的功能特定于ASP.NET平台,因此本课将对 MySolution.module.Web 进行更改。将视图控制器添加到 MySolution.module.Web 项目中的控制器文件夹中,如"添加简单操作"一课中所述。将其命名为"网络控制器"。

  • 调用控制器的设计器。在"属性"窗口中,将 TargetViewType 属性设置为"ListView" 值。这是必需的,因为控制器应仅出现在列表视图中。

    Tutorial_EF_Lesson10_1

  • Since you are going to access the settings of the List View's Grid Control, you need to ensure that it has already been created. This is why you need to subscribe to the Controller's ViewControlsCreated event. In the Properties window, switch to the Events view and double-click the ViewControlsCreated event. Handle the event as shown below.

 

由于您将要访问列表视图的网格控件的设置,因此您需要确保已创建该设置。这就是为什么您需要订阅控制器的视图控制创建事件。在"属性"窗口中,切换到"事件"视图并双击"查看控制创建"事件。处理事件,如下所示。

using System.Drawing;
using DevExpress.ExpressApp.Web.Editors.ASPx;
//... 
private void WebAlternatingRowsController_ViewControlsCreated(object sender, EventArgs e) {
    ASPxGridListEditor listEditor = ((ListView)View).Editor as ASPxGridListEditor;
    if (listEditor != null)
        listEditor.Grid.Styles.AlternatingRow.BackColor = Color.FromArgb(244, 244, 244);
}

 

  • As you can see in the code above, to access a list form's Grid, you should first get the ListEditor, which is the object that binds data to a Grid. To get the ListEditor, use the ListView.Editor property of the required List View. There are several types of built-in ASP.NET ListEditors. The code above is implemented when the current List View is represented by an ASPxGridListEditor. This ListEditor represents data via the ASPxGridView control. To access this control, the ASPxGridListEditor.Grid property is used.

 

  • 如您在上面的代码中所示,要访问列表窗体的网格,应首先获取 ListEditor,这是将数据绑定到网格的对象。要获取列表编辑器,请使用所需列表视图的 ListView.编辑器属性。有几种类型的内置ASP.NET列表编辑器。当当前列表视图由 ASPxGridList 编辑器表示时,将实现上述代码。此列表编辑器表示通过 ASPxGridView 控件的数据。要访问此控件,将使用 ASPxGridListEditor.Grid 属性。

 

  • Run the ASP.NET application. Select an item in the navigation control and ensure that the rows background is changed.

  • 运行ASP.NET应用程序。在导航控件中选择一个项目,并确保更改行背景。

    Tutorial_EF_Lesson10_2

Note 注意

Due to WinForms and ASP.NET platform specifics, View Item and List Editor controls may not be immediately ready for customization after the control is created. Consider handling additional platform-dependent events or using alternative approaches if the customizations above do not have any effect.

由于 WinForms 和ASP.NET平台细节,在创建控件后,视图项和列表编辑器控件可能不会立即准备好进行自定义。如果上述自定义项没有任何效果,请考虑处理其他与平台相关的事件或使用替代方法。

 

  • WinForms:

    Handle the System.Windows.Forms.Control

object's HandleCreated, VisibleChanged or ParentChanged

  • WinForms:

处理系统.Windows.窗体.控件

对象的句柄已创建、可见更改或父更改

 

  • events. You can also handle the Load (or similar) event if the current control type exposes it.

  • 事件。如果当前控件类型公开了"加载"(或类似)事件,也可以处理该事件。

 

  • ASP.NET:

    Handle the System.Web.UI.Control

object's Load or Init

  • ASP.NET:
    处理系统.Web.UI.控件
    对象的加载或 Init

 

  • server-side event. In certain cases, you may need to handle the WebWindow.PagePreRender event. Use the WebWindow.CurrentRequestWindowstatic property to get the current WebWindow object. You can also perform certain customizations on the client side using JavaScript (see Client-Side Functionality Overview).

  • 服务器端事件。在某些情况下,您可能需要处理 WebWindow.pageprein 事件。使用 WebWindow.CurrentRequest 静态属性获取当前 WebWindow 对象。您还可以使用 JavaScript 在客户端执行某些自定义(请参阅客户端功能概述)。

 

These additional platform-dependent events indicate the controls' "ready" state: a control has been added to the form controls hierarchy or has been bound to data. Contact us using the Support Center

if you need additional help to perform customizations.

These other events associated with the control platform indicating "ready" state: control has been added to the hierarchy or form control bound to data. Use our custom support center if you need additional help to perform.

 

Guess you like

Origin www.cnblogs.com/foreachlife/p/Access-Grid-Control-Properties.html