Topic: Looking for answers to some questions

Hello All –  I am hoping all of you pros out there have answers to some questions. I know the answer is looking me square in the face but I can't see it.

1.    I have noticed when I load my project that there is usually one button on the form that is highlighted. How do you keep that from happening?

2.     My second question is if you have a form that has a PageControl element with multiple tabs and your want to load the form to a specific tab how
        would you write the code? I like to use this element instead of creating multiple forms.

Re: Looking for answers to some questions

Hi,
To set which tabsheet is the 'default' when you first open your form, there are a couple of options.
1.  No Script Option,
Screenshot0 identifies the pageindex of the tabsheet you want to use as the 'default' and Screenshot1 uses that value as the tabindex property on the pagecontrol obect.
2.  Script Option (see screenshot 2).
As an alternative , add this bit of code using the index you identified in Screenshot 0.
You could also have this default index amendable by the user (useful if they are doing different tasks and, for the duration of that task, want a different tabsheet to always first open).
For the highlighted button question, have a look at screenshot 3.  All forms have one button set as the 'default' which means that it is both highlighted when you open the form and also that you can simply press 'enter' and the button action will fire.
Simply untick the 'default' box (to have no button set as default) or untick it and then tick another button to change the default.
Regards,
Derek.

Post's attachments

Attachment icon tjohnson.zip 589.3 kb, 271 downloads since 2021-11-29 

Re: Looking for answers to some questions

As usual, you are awesome... Thanks, Derek

Re: Looking for answers to some questions

Dear derek

Kindly need private work for application.
Tried to send u direct mag cant

Re: Looking for answers to some questions

Hi,
If you need help, the best thing to do is to upload your project to this Forum with a full description of what your issues are.  The more information you can provide, the more likely you are to get a focussed response from other users.
Most of us use google translator so you can always post in your native language.
Derek.

6 (edited by joshuA 2021-12-01 23:49:38)

Re: Looking for answers to some questions

Hi tjohnson0473 and derek,
.
A little late here, but great questions. I learned something, so I just wanted to comment.
.
I knew how to set the tabindex with scripts, but I wasn't aware that the PageControl had a property for doing this.  Or if I did, I had forgotten about it and had been doing it with scripts.
.
I have also noticed the behavior you described in your first question, but I've never been able to identify what was causing it.  I always tried to control it using the TabOrder properties, but this further explains the unsolved mystery for me.
.
Thank you, thank you big_smile

"Energy and persistence conquer all things."

Re: Looking for answers to some questions

Hi again,
.
So after further experimenting with derek's first option, I would like to clarify something, which is why I prefer the scripting method for this...
.
Changing the TabIndex property within the PageControl, is the same as selecting that tab in design mode.  Thus, the tab that was last selected becomes the tab that is first shown when the form loads.  So the TabIndex property in the PageControl is not fixed because it also changes to the tab that was selected prior to running the project.
.
To me, this is not really "setting a default".  Because while I'm designing a project, I don't always go back and select the tab that I wish to show when the form loads (mostly because I forget to do this).
.
It would be nice to have this option without scripting though...
.
Just my two cents wink

"Energy and persistence conquer all things."

Re: Looking for answers to some questions

Hi Joshua,
As I mentioned in my earlier post, another option that you could consider is to use a data-driven approach and hold a small table where you can specify which tabsheet you want to show on startup.
In the attachment, simply change the 'default' tabsheet setting on Form3, restart your application, and a different default now shows.
You can do similar things throughout your application (variable tool tips, variable captions etc etc).
Derek.

Post's attachments

Attachment icon default tabindex.zip 339.19 kb, 255 downloads since 2021-12-02 

Re: Looking for answers to some questions

Hi derek,
.
Pardon me for overlooking that suggestion. I haven't really thought about using the database for persistent settings like that.  Very handy though!  I'll have to remember this for later on.
.
Many many thanks as always and for your examples too!

"Energy and persistence conquer all things."

10 (edited by dbk 2021-12-02 20:35:11)

Re: Looking for answers to some questions

derek wrote:

Hi Joshua,
As I mentioned in my earlier post, another option that you could consider is to use a data-driven approach and hold a small table where you can specify which tabsheet you want to show on startup.
In the attachment, simply change the 'default' tabsheet setting on Form3, restart your application, and a different default now shows.
You can do similar things throughout your application (variable tool tips, variable captions etc etc).
Derek.

Very clever, as always! thx Derek


@Joshua


to fix a certain tab on startup maybe you can also try something like this with script on your main form onshow procedure:

procedure frmMain_OnShow (Sender: TObject; Action: string);

begin
    frmMain.PageControl1.ActivePageIndex := 0; // tab 1
end;

Re: Looking for answers to some questions

Hi dbk,
.
Yes, that's usually how I handle it.  Except I have been using

frmMain.PageControl1.TabIndex := 0;

I glanced over the help documents comparing the two, but I didn't quite understand the difference. hmm

"Energy and persistence conquer all things."