DevExpress Gridcontrol Use Method Summary 2 Property Description

Source: Internet
Author: User

First, how to resolve the issue that the click Record whole row is selected

View->optionsbehavior->editorshowmode is set to: Click

Second, how to add a record

(1), Gridview.addnewrow ()

(2) Implementation of Gridview_initnewrow events

Third, how to solve the problem that Gridcontrol records can be obtained without showing

Gridview.populatecolumns ();

Iv. How to make a row only selectable and not editable (or edit a cell)

(1), View->optionsbehavior->editorshowmode set to: Click

(2), view->optionsbehavior->editable set to: false

V. How to disable Gridcontrol click on the column popup context menu

Set run Design->optionsmenu->enablecolumnmenu to: false

Vi. How to hide the Gridcontrol grouppanel table head

Set run Design->optionsview->showgrouppanel to: false

Vii. How to disable filter for column header in Gridcontrol

The filter looks like this:

Set Run Design->optionscustomization->allowfilter to: false

Viii. How to display a custom character prompt/display when a query gets 0 records

Here's how:

When no Records is Being Displayed
private void Gridview1_customdrawemptyforeground (object sender, Customdraweventargs e)
{
Method One (this method sets the data source binding for the GridView, available)
Columnview Columnview = sender as Columnview;
BindingSource BindingSource = This.gridView1.DataSource as BindingSource;
if (Bindingsource.count = = 0)
{
String str = "No query to the data you want!";
Font f = new font ("Arial", ten, FontStyle.Bold);
Rectangle r = new Rectangle (E.bounds.top + 5, E.bounds.left + 5, e.bounds.right-5, e.bounds.height-5);
E.graphics.drawstring (str, F, Brushes.black, R);
}
Method Two (this method is not set for the GridView data source binding, use, general use of this method)
if (This._flag)
{
if (This.gridView1.RowCount = = 0)
{
String str = "No query to the data you want!";
Font f = new font ("Arial", ten, FontStyle.Bold);
Rectangle r = new Rectangle (E.bounds.left + 5, E.bounds.top + 5, e.bounds.width-5, e.bounds.height-5);
E.graphics.drawstring (str, F, Brushes.black, R);
}
}
}

Nine, how to display the horizontal scroll bar?

Set this.gridView.OptionsView.ColumnAutoWidth = false;

Ten, how to locate the first data/record?

Set This.gridView.MoveFirst ()

Xi. How to navigate to the next data/record?

Set This.gridView.MoveNext ()

12, how to locate the last data/record?

Set This.gridView.MoveLast ()

13. Set to select one row at a time and cannot be edited

This.gridView1.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
This.gridView1.OptionsBehavior.Editable = false;
This.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;

14. How do I display the line number?

This.gridView1.IndicatorWidth = 40;
Display the ordinal of a row
private void Gridview1_customdrawrowindicator (object sender, Rowindicatorcustomdraweventargs e)
{
if (E.info.isrowindicator && e.rowhandle>=0)
{
E.info.displaytext = (E.rowhandle + 1). ToString ();
}
}

XV, how to let the column head prohibit movement?

Set gridView1.OptionsCustomization.AllowColumnMoving = false;

16, how to let the column headers prohibit sorting?

Set gridView1.OptionsCustomization.AllowSort = false;

17, how to prohibit the column head to change the column width?

Set gridView1.OptionsCustomization.AllowColumnResizing = false;

DevExpress Gridcontrol Use Method Summary 2 Property Description

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.