LiveCode LessonsData GridLiveCode Data GridWorking With Data Grid TablesHow Do I Determine If a User Clicks In The Table Header?

How Do I Determine If a User Clicks In The Table Header?

This lesson will show you how to determine if the user clicked in the header of a Data Grid table by showing you how to use the dgHeaderControl and dgHeader properties of the target control that was clicked on.

The Table Header

The Table Header

A Data Grid table has a header where the column names are displayed (1). When a user clicks in the header with the mouse the dgHeader of the target returns the long id of the group control that contains all of the header controls.

When the user clicks on a column header (2) the dgHeaderControl of the target returns the long id of the group control that contains all of the column header controls.

Example

Example

Here is some sample code that prints off the dgHeaderControl and dgHeader properties when the user clicks on a Data Grid. You can place this script in the Data Grid script.

==========

Copy & Paste

==========

on mouseDown pBtnNum
	put "Column header control:" && the dgHeaderControl of the target \
			 & cr & cr & "Header control:" && the dgHeader of the target
end mouseDown

After adding the script to the Data Grid the value of the dgHeaderControl and dgHeader properties are displayed in the message box. In this example both properties return the long id of a control (1) because I clicked on a column header (2).

In this example only the dgHeader property returns the long id of a control (1) because I clicked in the table header but not on a column header (2).

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.