Raise event in custom component

Post

Posted
Rating:
#1 (In Topic #894)
Regular
bill-lancaster is in the usergroup ‘Regular’
 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)?
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
 Have you tried setting the index in the _Show event not _new ?
Or your form_open
The control has not yet initialised in _new
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
bill-lancaster is in the usergroup ‘Regular’
 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.
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Guru
cogier is in the usergroup ‘Guru’
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()?
Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
bill-lancaster is in the usergroup ‘Regular’
 Thanks cogier, GridView1_Arrange() does the job.
'Raise ChangeCat' in _new() doesn't work.
Thanks again
Online now: No Back to the top

Post

Posted
Rating:
#6
Guru
BruceSteers is in the usergroup ‘Guru’
can you not just run the event command from the main form on load without requiring the initial trigger?

Ie..

Code (gambas)

  1. Public Sub Form_Open()
  2.  
  3.   MyControl_ChangeCat()
  4.  
  5.  
just make sure the ChangeCat() sub uses direct links to the Control not the "Last" keyword

or in the Form_Open() explicitly set the gridview row

Code (gambas)

  1. Public Sub Form_Open()
  2.  
  3.   MyControl.Grid1.Select(0)
  4.  
  5.  
(or however you would set the grid item)
Online now: No Back to the top

Post

Posted
Rating:
#7
Guru
BruceSteers is in the usergroup ‘Guru’
 also did you try the special method  _ready() ?
Online now: No Back to the top

Post

Posted
Rating:
#8
Regular
bill-lancaster is in the usergroup ‘Regular’
 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
Online now: No Back to the top
1 guest and 0 members have just viewed this.