[Lazarus] DBGrid columns shrunk to fit data

Graeme Geldenhuys graemeg at opensoft.homeip.net
Wed Jun 17 16:49:14 CEST 2009


On Wed, 17 Jun 2009 09:04:55 +0200
Graeme Geldenhuys <graemeg at opensoft.homeip.net> wrote:

> Hi,
> 
> I have code defined as follows (it's a fpGUI Toolkit project). Here I
> have a Form with 2 Buttons on it. No event handlers have been defined
> yet.
> 
>   TMainForm = class(TfpgForm)
>   private
>     {@VFD_HEAD_BEGIN: MainForm}
>     btnCreate: TfpgButton;
>     btnDebug: TfpgButton;
>     {@VFD_HEAD_END: MainForm}
>   public
>     procedure AfterCreate; override;
>   end;
> 
> 
> Inside the AfterCreate() method is the code that initializes the GUI.
> fpGUI doesn't use external *.lfm files like Lazarus LCL projects.
> 
> Anyway, I add a OnClick event handler in the AfterCreate method for
> one of the buttons.
> 
>   btnDebug := TfpgButton.Create(self);
>   with btnDebug do
>   begin
>     ...
>     OnClick := |      //   | is the cursor position
>   end;
> 
> I then press Ctrl+Shift+C to fire off code completion which creates
> the event handler.  This is the result:
> 
>   TMainForm = class(TfpgForm)
>     procedure btnDebugClick(Sender: TObject);
>   private
>     {@VFD_HEAD_BEGIN: MainForm}
>     btnCreate: TfpgButton;
>     btnDebug: TfpgButton;
>     {@VFD_HEAD_END: MainForm}
>   public
>     procedure AfterCreate; override;
>   end;
> 
> 
> But that is not really what I wanted. I wanted the btnDebugClick
> method to be private, not published. Published is the default
> visibility if no visibility is specified.  The following code is
> actually what I wanted:
> 
>   TMainForm = class(TfpgForm)
>   private
>     {@VFD_HEAD_BEGIN: MainForm}
>     btnCreate: TfpgButton;
>     btnDebug: TfpgButton;
>     {@VFD_HEAD_END: MainForm}
>     procedure btnDebugClick(Sender: TObject);
>     procedure btnCreateClick(Sender: TObject);
>   public
>     procedure AfterCreate; override;
>   end;
> 
> 
> Is there any way I can tune my Code Completion to do this? If so, what
> settings must I change?  Or is that something hard-coded into Code
> Completion that cannot be changed?
> 
> Even after I manually moved the btnDebugClick() event handler to the
> correct location in the 'private' area, when I create the second event
> handler for the Create Button, Code Tools again places the event
> handler in the published section.
> 
> In Code Tools I have "Class part insert policy" set to "Last" and
> "Method insert policy" set to "class order".

At the moment the events are always added to the first published
section.

You can create a feature request for an option. For example
first published, public, protected, private, ask. "Ask" will popup
a dialog. Don't forget to make a nice proposal for the option name.

Mattias




More information about the Lazarus mailing list