Datagrid question

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Datagrid question

Post by phaworth » Thu Mar 04, 2010 6:54 pm

I would like to display a button next to the currently selected line in a datagrid, making it clear that clicking the button will cause an operation on the data in that line. The dgHilitedLine property tells me which line is currently selected so I guess I'm looking for a way to convert that to a vertical screen position so I know where to position the button.
Thanks,
Pete

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Datagrid question

Post by trevordevore » Thu Mar 04, 2010 7:59 pm

There is an undocumented dgRectOfIndex property (put the dgRectOfIndex[theIndex] of group "DataGrid") that you might be able to use. As long as the control is visible on screen or you have control caching turned on then a rect will be returned.

Questions though - Will the button need to move if the data grid is scrolled? If so then you might consider putting the button in the actual row itself.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Re: Datagrid question

Post by phaworth » Thu Mar 04, 2010 8:39 pm

Thanks for the info Trevor and for pointing out what I had not considered - the scrolling. I guess I had been hoping to save real estate in the datagrid by positioning the button as I mentioned rather than as a column in the datagrid.

I guess another option might be to use a double click on a line to signify the action, or even a right click over the line to bring up a popup menu if there are multiple action choices. I think I've seen discussions of both those things in the datagrid manual and on the forum.

Pete

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: Datagrid question

Post by trevordevore » Thu Mar 04, 2010 8:44 pm

I often use a contextual menu myself. Here is a lesson.

How Do I Add a mouseDown Event To The Data Grid Without Breaking It?
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”