One of the use of DatagID controls in DEV

xiaoxiao2021-04-04  278

(1) Use of DEV control GridControl

1. Confirm the input of the cell currently editing this.gridView1.closeEditor ();

2, save the value of the current row to the data source this.gridView1.Updatecurrentrow ();

3. Update the modification to the database SqlDataAdapter1.Update (MyDataSet, "MyTable") / / can be executed directly by DataAPter.

Follow the steps performed 1,2,3; may be achieved by steps 1 and 2 initialize and (2) DataGrid by Sql gridView1.OptionsView.EnableAppearanceEvenRow = true; gridView1.OptionsView.EnableAppearanceOddRow = true; gridView1.OptionsView.ShowFilterPanel = false ; gridView1.OptionsView.ShowGroupPanel = false; gridView1.OptionsView.ShowGroupPanel = false; gridView1.OptionsSelection.EnableAppearanceFocusedCell = false; gridView1.OptionsBehavior.Editable = false; gridView1.OptionsCustomization.AllowColumnMoving = false; gridView1.OptionsCustomization.AllowColumnResizing = false; gridView1 .Optionscustomization.allowgroup = false; gridowfilter = false; GridView1.OptionScustomization.allowsort = true; (3) Get the contents of the selected row and the selected line

int

[] A

=

THIS

.gridview1.getSelectedRows ();

//

Pass the entity class to get the selected line

Laa.assetguid

=

THIS

.gridview1.getrowcellvalue (a [

0

],

"

AskGUID

"

.Tostring ();

//

Get the contents of the selected line

(4) The mutual calls of the Button control are button1_click (null, evenetargs.empty); DEV control is simpleButton1_Click (New Object (), New Eventargs ()); (5) How to XTRID Verify that the value of the cell We verify if the value of each cell is correct in the case of XtraGrid directly entering the data. There are two ways to implement a cell-based verification: 1. "Sender" using the repositoryItem.validating event event must be converted to the BaseEdit type, use EditValue to get the current input value and check, if the verification is not passed, E.CANCEL Setting true. This method is generally used to perform data verification of the cells of the built-in control 2. Use the "Sender" of the GridView.validAnGeditor event event to be converted to a GridView type, and the current column can be obtained from the GridView.FocusedColumn property, the value can be obtained from E.Value If the verification is not passed, you need to set the E.valid to false.. This approach is generally used to verify the text box within the entire grid. You need to write a GridView.INValidValueException event devices after setting the event: for example: Private

Void

GridView1_INValidValueException

Object

Sender, defexpress.xtragrid.views.base.invalidValueExceptionEventArgs e)

{E.THROWEXCEPTION = false; E.WindowText = "The new value is invalid. Please correct it or press esc to abandon your change."; E.displayerror = true;}

(6) Barmanager's specific settings After adding the Barmanager control, select [Click Here to Tool Bar] in [Click Here to Tool Bar] [Click Here to Tool Bar] to fill in the toolbar button that needs to be added. Designer into the inside, select ToolBars -> Custom 1-> OptionsBar inside the following settings: AllowQuickCustomization = falseDrawDragBorder = falseRotateWhenVertical = falseUseWholeRow = True 4 above initial setting items (7) which increase the status bar DataGrid StaticText first increases in the new inside BarManager The additional BarstaticItem's AutoSize is set to Spring and then write the following code:

Private

Void

STATECOTE ()

{IF (GridView1.Rowcount! = 0) {INT A = this.gridview1.rowcount; barstaticItem1.caption = "Current a total of records:" a.tostring (); int [] b = this.gridView1.getSelectedRows (); B [0] = 1; BarsTaticItem2.caption = "Currently:" b [0] .tostring ();} else {barStaticItem1.caption = "Current record:"; barstaticItem2.caption = "Current:" }} Private

Void

GridControl1_click

Object

Sender, System.EventArgs E)

{Statecote ();

Private

Void

GridView1_focusedrowChanged (

Object

Sender, deVexpress.xtragrid.views.base.focusedrowChangeDeventargs E)

{Statecote ();

(8) DateTable fills DataGrid References here:

Using

DevexPress.Utils;

/ ** /

///

/// According to DataTable population DataGrid ///

Private

Void

DisposedDataGrid (DataTable DT)

{// center the title gridView1.Appearance.HeaderPanel.TextOptions.HAlignment = HorzAlignment.Center; this.gridControl1.DataSource = dt; gridView1.Columns [0] .Visible = false; // exception log GUID gridView1.Columns [1]. Visible = false; // Passage GridView1.columns [2] .visible = false; // Channel number GridView1.Columns [3] .caption = "channel name"; GridView1.columns [3] .width = 100; GridView1. Column [4] .caption = "card number"; GridView1.columns [4] .width = 100; GridView1.columns [5] .caption = "cardholder name"; GridView1.columns [5] .width = 60; GridView1 .Columns [6] .caption = "Master card number"; GridView1.columns [6] .width = 100; GridView1.columns [7] .caption = "Main Cardroom"; GridView1.columns [7] .width = 60; GridView1.columns [8] .caption = "Pass Time"; GridView1.Columns [8] .width = 100; GridView1.columns [9] .caption = "license plate number"; Gridview1.columns [9] .width = 60; GridView1.columns [// Image Guid GridView1.columns [11] .caption = "Abnormal Description"; GridView1.columns [11] .width = 100; GridView1.Columns [12] .caption = "Processing Results"; GridView1.Columns [12] .width = 100; GridView1.columns [13] .visible = false; // ImageID // can be sorted by GridView1.OptionScustomization.Allowsort = True;} where there is a collection time type

GridView1.columns [

3

] .Caption

=

"

Operating time

"

GridView1.columns [

3

] .Width

=

200

GridView1.columns [

3

] .Unboundtype

=

Devexpress.Data.UnboundColumnType.Datetime; GridView1.columns [

3

] .DisplayFormat.FormatString

=

"

Fly

"

GridView1.columns [

3

] .DisplayFormat.FormatType

=

Formattype.datetime;

(9) Double-click DataGrid pop-up details

Private

Void

GridControl1_doubleclick

Object

Sender, System.EventArgs E)

{// Double-click the pop-up exception log description IF (this.gridView1.rowcount> 0) {int [] a = this.gridView1.getSelectedRows (); string str_guid = this.gridView1.GetrowcellValue (a [0], "EX_no") .Tostring (); // Get an exception number messagebox.show (str_guid); frMexceptionLogDesc DLG = new fmExceptionLogDesc (); DLG.Text = "Exception log view"; dlg.showdialog ();}}

转载请注明原文地址:https://www.9cbs.com/read-131807.html

New Post(0)