Recent

Author Topic: Buttons in stringgrid always visible?  (Read 14284 times)

PeterH

  • New Member
  • *
  • Posts: 31
Buttons in stringgrid always visible?
« on: August 06, 2010, 07:50:14 pm »
Hello,

I'm using a stringgrid with 8 rows and three columns. In the last column I want to display 8 buttons.
All the 8 buttons are always visble. (= not only visible when the cell is selected).

I looked at this thread to fit the buttons in the cells but it doesn't work.

http://http://forum.lazarus.freepascal.org/index.php?topic=2753.0

The button appears only in the selected cell. The option ' alwaysshoweditor' doesn't do anything.

Does anybody has a solution for this?

Thanks in advance

jesusr

  • Sr. Member
  • ****
  • Posts: 484
Re: Buttons in stringgrid always visible?
« Reply #1 on: August 06, 2010, 10:43:07 pm »
if you want to have 8 buttons in each cell of las column that makes 64 independent buttons. I think grids internal editor support will not help you in this case because they were designed to show the editor only on selected cell, the exception is cbsCheckboxColumn which shows a checkbox always, but that is custom drawn

if the grid is not scrollable, I guess you can do it pretty much by just caculating the coords of the 64 buttons and put them on the grid, if grid it's scrollable you have to take in count some events in order to reposition them.

other way doing is like the case of checkboxcolumn, drawing the buttons your self, using themes support you can draw the buttons to look much like ordinary buttons, in this case you have to handle mouse events on buttons your self too, but you only have to draw the 1 button eight times at different position using OnDrawCell, in this method scrollable or not doesn't matter.

PeterH

  • New Member
  • *
  • Posts: 31
Re: Buttons in stringgrid always visible?
« Reply #2 on: August 06, 2010, 11:01:58 pm »
Hello JesusR,

I only want 1 button per row. The grid has 8 rows so 8 buttons in a column.
The grid is not scrollable so calculating the position for a button control array is indeed possible.
I'm going to look into that.

In Delphi there are grids (like the Advanced Stringgrid) which already have all this functionallity. I was also wondering if there are that kind of grids available for Lazarus.

jesusr

  • Sr. Member
  • ****
  • Posts: 484
Re: Buttons in stringgrid always visible?
« Reply #3 on: August 07, 2010, 01:40:54 am »
Oh so I misunderstood, instead of 8 buttons per cell is just one, for standard grid the options do not change too much.

I have seen some people talk about kgrid and orpheus grids. Some developers had converted some thirdparty grids like adv? grids or something but I have not used any of them, lets wait they pronounce them selves if those grids can make the job.

Just for curiosity, in the grid you know which can use buttons, the button occupy the whole cell area?, just a part and is aligned?, the button has caption?

PeterH

  • New Member
  • *
  • Posts: 31
Re: Buttons in stringgrid always visible?
« Reply #4 on: August 07, 2010, 02:29:03 pm »
I don't want to use ported grids from Delphi which aren't free. TMS grids aren't free.
I used to work with Delphi for my former employer and choose Lazarus because it's free. Now (as a hobby) I'm making commercial software so it has to be legal. Don't have the money (yet) to buy a Delphi licence and I probably never will buy one because Lazarus can do everything I want.

The buttons occupy the whole cell (in column 3). When clicked a list pops up. From this list 1 item can be selected which is then shown is column 2. See the attachment

I tried the 'draw and place your own' method and it works ! It's a lot of coding but....it works

« Last Edit: August 07, 2010, 03:49:52 pm by PeterH »

jesusr

  • Sr. Member
  • ****
  • Posts: 484
Re: Buttons in stringgrid always visible?
« Reply #5 on: August 08, 2010, 04:49:24 am »
Implemented in Lazarus r27029, check http://wiki.lazarus.freepascal.org/Grids_Reference_Page#Grid_Cell_Editors for some documentation about it.

PeterH

  • New Member
  • *
  • Posts: 31
Re: Buttons in stringgrid always visible?
« Reply #6 on: August 08, 2010, 12:47:36 pm »
Great ! I didn't see the part about the ButtonColumn and Checkboxcolumn.

When I look in my 'Lazarus About' I see versionnumber 0.9.29. Is the correct version?

 

TinyPortal © 2005-2018