Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6360371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:38:28+00:00 2026-05-24T23:38:28+00:00

I am working with Delphi Prism for .NET. I need to call a public

  • 0

I am working with Delphi Prism for .NET. I need to call a public method in my mainform class from another winform method. So, having recently learned about static, I used it in my program. Static or Class winform works great, but making a method static or class doesn’t seem to work the same.

I have a method called updateButtons in my mainform class. It updates all the buttons and controls on the mainform according to the user’s action. This method needs to be called from another winform method. So, I made that UpdateButtons method into static or class. Although now I see the method to call, compiler doesn’t like. It keeps raising the following error, “Cannot call instance member (Any controls) without an instance reference.”

How can you make a method a class or static and still have access to controls from the winform?

Main class with static or class method:

  MainForm = partial class(System.Windows.Forms.Form)
  private
  protected
    method Dispose(disposing: Boolean); override;
  public
    class method updateButtons;
  end;

definition of updatebutton:

class method MainForm.updateButtons;
begin    
        if SecurityEnabled then
                LoginBtn.Enabled := true       //All the lines where I call Buttons raise the error exception that I mentioned above.
        else
        begin
                UnitBtn.Enabled := true;
                SignalBtn.Enabled := true;
                AlarmBtn.Enabled := true;
                MakerBtn.Enabled := true;
                TrendBtn.Enabled := true;
                DxCommBtn.Enabled := (Scanning = false);
                TxBtn.Enabled := true;
                ControlBtn.Enabled := true;
                PIDBtn.Enabled := true;
                SystemBtn.Enabled := true;
                WinListBox.Enabled := true;
                WinBtn.Enabled := true;
                ShutdownBtn.Enabled := true;
                OptionBtn.Enabled := true;
                LoginBtn.Enabled:=false;
        end;
  end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:38:29+00:00Added an answer on May 24, 2026 at 11:38 pm

    Since the method I want to execute is from MainForm Window Form and fired from within a button event, I decided to call that method from within the Button Click event from MainForm instead of from other winform. This has the same end result. Plus, it is simpler.

    //This is just a sample code
    MainForm = class(system.windows.forms.form)
    private
        method ScanBtn_Click(sender: System.Object; e: System.EventArgs);
    protected
    public
        Method UpdateButtons;
    end;
    
    Method Mainform.UpdateButtons;
    begin
       Button1.enabled:=true;
       Button1.text:='Start Scanning';
    end;
    
    method MainForm.ScanBtn_Click(sender: System.Object; e: System.EventArgs);
    begin
        if not Scanning then
            stopthread:=true;
    
        dxCommWin.Scan(not Scanning);
        UnitWin.UpdateMenu;  
        UpdateButtons; <-------I call it here instead of from dxCommWin.Scan Method.
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with Delphi Prism for .NET. I need to be able to
I'm working in Delphi 2007. Net, where I can find an example of using
I am working on a Delphi project, where i need to export values to
I am currently working with Delphi Prism for Mono development. So, the software can
I'm having a hard time with a query in MySQL. I'm working with Delphi
I am working with Delphi Prism and creating and writing into binary file using
I am working with Delphi 2010 and the ShellAPI. I need a little help
I followed these instructions while trying to get remote debugging working with Delphi 2007.
Working on a service application in Delphi 5 that is intended to run on
I have a simple Delphi program that I'm working on, in which I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.