Re: generic panel focus



woah. thanks, that's so simple... I didn't think that'd change the
panel cod for each specific one, since it has been assigned a name in
the procedure section, but it does. nice :)
thanks for the help... that will come in handy in the future..

breaker19@xxxxxxxxxxxx wrote:
Highlight the first of your panels in the form designer. Press F11 to
get the Object Inspector.
On the Events tab, double-click the OnEnter property.

Write a code snippet similar to this:

--------------------------8<--------------------------------------------------------------
procedure TForm1.Panel1Enter(Sender: TObject);
begin
// do something - for example
Caption := 'Entered control is ' + (Sender as TPanel).Name;
end;
-------------------------8<----------------------------------------------------------------

Now use the object inspector to put this same event code on all of your
panels. When you highlight the second panel you will see this procedure
in the drop-down for the OnEnter event.

You now have this same bit of code being executed when ANY of your
panels is entered. The SENDER parameter will be the panel that is
entered. So when a user enters panel#7, "Sender" will be Panel#7, and
so on.

Notice that to get any of the properties of the entered panel, you need
to cast Sender as a TPanel- like this: (Sender as TPanel).property -
where property can be any of the panel's properties - width, top, tag,
caption, name, etc.

The event is fired whenever a user tabs to a panel, or clicks on a
control on the panel. It is not fired when the user just clicks on the
panel. Note that it will be fired at start-up if the first panel is the
first control.


piraticman@xxxxxxxxx wrote:
Hi. I'm trying to make a generic code for focused panels, so I don't
have to put the same code in numerous panels.

I have about 10 panels and the tabstop is true. What I'm trying to
figure out some code to check the currently focused panel for a
character in the name and do a task accordingly.

It should be something like:

if currently focused panel's name has the first character as A
(focusedpanel.name [1] = A)
then

execute code...

This is basically so I can tab through all pannels and any that start
with an A in the name will execute a certain code.

thanks

.



Relevant Pages

  • Drucken eines Panel-Control
    ... auf einem Panel zeichne ich verschiedene Figuren, ... private panel_Paint(Object sender, PaintEventArgs pea) ... protected void menuFilePrint_Click(Object sender, EventArgs e) ... PrintDialog printDialog = new PrintDialog; ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: PPC flicker problem.
    ... the picture in the panel should also move following the mouse... ... I use the Bitblt, but it doesn't work. ... private void panelMap_MouseMove(object sender, ...
    (microsoft.public.pocketpc.developer)
  • Re: looping
    ... component seen as a TObject. ... Simply use (Sender as TPanel) to get the sending panel. ...
    (borland.public.delphi.ide)
  • Re: Event firing twice in UserControl issue
    ... fire twice. ... with no panel) with a panel then a custom ListControl. ... Private Sub radiobuttonlist1_selectedvaluechanged(ByVal sender As Object, ... Private Sub RadioPanel1_SelectedValueChanged(ByVal sender As Object, ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Passing System.EventArgs as parameters
    ... Private Sub PaintBorder(ByVal sender As Object, ... How would I call this function if I wanted to paint a border on a panel ...
    (microsoft.public.dotnet.languages.vb)