I have a custom component containing a gridview which is populated and the first row selected in the _new() procedure.
Clicking on a row in the gridview raises an event ('ChangeCat' in my project).
How to raise this event as soon as the control is loaded (i.e. with no further user action)?
Raise event in custom component
-
- Posts: 195
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
- BruceSteers
- Posts: 1570
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Raise event in custom component
Have you tried setting the index in the _Show event not _new ?
Or your form_open
The control has not yet initialised in _new
Or your form_open
The control has not yet initialised in _new
If at first you don't succeed , try doing something differently.
BruceS
BruceS
-
- Posts: 195
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
Re: Raise event in custom component
Thanks Bruce,
This control draws 2 gridviews , a buttonbox etc all inside a Frame (hFrame) on the parent form so hFrame doesn't have a _Open or _Show event.
Have just tried hFrame_Activate() and hFrame_GotFocus() but these events aren't triggered.
Hope this makes sense.
This control draws 2 gridviews , a buttonbox etc all inside a Frame (hFrame) on the parent form so hFrame doesn't have a _Open or _Show event.
Have just tried hFrame_Activate() and hFrame_GotFocus() but these events aren't triggered.
Hope this makes sense.
- cogier
- Site Admin
- Posts: 1125
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Raise event in custom component
Try GridView1_Arrange(). This is triggered when the GridView has finished arranging its contents. NOTE that if you change anything or resize the Form this will be triggered.
Can't you simply call ChangeCat as the last command in _new()?
Can't you simply call ChangeCat as the last command in _new()?
-
- Posts: 195
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
Re: Raise event in custom component
Thanks cogier, GridView1_Arrange() does the job.
'Raise ChangeCat' in _new() doesn't work.
Thanks again
'Raise ChangeCat' in _new() doesn't work.
Thanks again
- BruceSteers
- Posts: 1570
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Raise event in custom component
can you not just run the event command from the main form on load without requiring the initial trigger?
Ie..
or in the Form_Open() explicitly set the gridview row
Ie..
Public Sub Form_Open()
MyControl_ChangeCat()
End
just make sure the ChangeCat() sub uses direct links to the Control not the "Last" keywordor in the Form_Open() explicitly set the gridview row
Public Sub Form_Open()
MyControl.Grid1.Select(0)
End
(or however you would set the grid item)
Last edited by BruceSteers on Sunday 28th August 2022 7:59pm, edited 3 times in total.
If at first you don't succeed , try doing something differently.
BruceS
BruceS
- BruceSteers
- Posts: 1570
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Raise event in custom component
also did you try the special method _ready() ?
If at first you don't succeed , try doing something differently.
BruceS
BruceS
-
- Posts: 195
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
Re: Raise event in custom component
Thanks Bruce,
Putting the raise event in _Ready() doesn't work.
I've been running the event from the parent form but was trying to skip this step.
In the _new() sub, the table is filled with data and the first line is selected. At the moment gridview_Arrange() works fine.
Thanks again
Putting the raise event in _Ready() doesn't work.
I've been running the event from the parent form but was trying to skip this step.
In the _new() sub, the table is filled with data and the first line is selected. At the moment gridview_Arrange() works fine.
Thanks again