Documents

NextGrid & NextDBGrid

NextGrid

NextDBGrid

NextInspector

NextSheet

NextCollection

Misc

Labs

NextGrid .NET

Edit events in NextGrid

Related Articles:

Info
  • Skill:
  • Version: 1.0.0
  • Author: Bojan Nikolic
  • Created:
  • Updated: 2008-04-21
NextGrid have many events, such as: OnSelectCell, OnHeaderClick, OnFooterClick...but, events trigered while User editing Cell are one of most important.

NextGrid have several events used in editing cell process. They are occur in next order:



OnBeforeEdit



This event first occur. It occur before cell jump into editing state:

1. By clicking on Cell
2. Start typing in Cell or
3. Calling EditCell method.

With using Accept parameter inside this event cell may prevent from editing. ACol and ARow parameters represents cell to be edited.

{ Cell 3, 4 can't be edited! }
if (ACol = 3) and (ARow = 4) then Accept := False;

{ Cancel if cell content is empty string }
if NextGrid1.Cells[ACol, ARow] = '' then Accept := False;


OnApplyEditText



This event occur immidiatelly after OnBeforeEdit, in moment when cell's value need to be transfered to InplaceEditor. This event include Value parameter with which edit text may be adjusted.

For example, if in cell value is "Jim@mail.cor", we may adjust it to "jim@mail.com" and similar examples.

if Value = '' then Value = 'none';
if IsValidEmail(Value) then Value := ValidEmail(Value);


OnEdit



OnEdit event occur in many situations when grid is in edit mode. It may occur when text is changed, new letter is typed, text is copyed or cleared or even new value is selected from drop-down control. It include Value parameter determining current value of text inside InplaceEditor.

OnEditAccept



This event occur when user finish with editing (select another cell, press Enter key...). This event include var Accept parameter which specify whathewer newly edited text will be accepted at all or editing will be simply finished without any changes made (OnEditExit event is called only).

if Value = '' then Accept := False;
if Value = 'inapropriate value' then Accept := False;
Accept := Length(Value) > 3;


OnAfterEdit



This event occur after editing is finished successfully.

OnEdiExit



This event occur at the end, it occurs even if editing is successfully done or canceled. This event is usefull when some resources need to be freed or some repainting to be done.

InplaceEditor



While grid is in editing process, InplaceEditor property is available.

This property actually represent editing control assigned to edited cell (edit box, combobox, date-picker...). You may access to it by using typecast for specific properties of some InplaceEditors. For example:

if TNxComboBox(NextGrid1.InplaceEdit).DropDownCount = 5 then ...


This area of component is upgraded durring time, and event names are maybe not 100% accurate due to keeping compatibility to older versions. If you have any suggestion or question do not hesitate to ask us.

Was This Article Useful?

Only constructive comments, code contributions... will be publishes. Questions, non-official discussion will not be published.