N
N
NikitaSova2020-09-16 09:01:55
JavaScript
NikitaSova, 2020-09-16 09:01:55

How to solve error CS0120?

Hi all.
today I wanted to make a button press by pressing a key on the keyboard, but I ran into a problem that I don’t know how to solve. Hope you can tell me how to solve it. thanks in advance
code:

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
class MyButtonClass : Form
{

    private Button One, Two, Three, Four, Fife, Six, Seven, Eight, Nine, Zero, Plus, Minus, multiply, division, Equally, dot, Delete, clear, copy, past;
    private TextBox FirstText, SecondText, ThirdText;


    private void InitializeComponent()
    {
        this.SuspendLayout();
        // 
        // MyButtonClass
        // 
        this.ClientSize = new System.Drawing.Size(280, 525);
        this.Name = "MyButtonClass";
        this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
        this.ResumeLayout(false);

    }

    double n, k, res;
    int v, b;

    public MyButtonClass()
    {
        v = 0;
        b = 0;

        Plus = new Button();
        Plus.Text = "+";
        Plus.Top = 150;
        Plus.Left = 210;
        Plus.Height = 100;
        Plus.Width = 70;
        Plus.Click += new System.EventHandler(PlusButton);
        this.Controls.Add(Plus);
        //Declare, properties and call a button

        FirstText = new TextBox();
        FirstText.Text = $"0";
        FirstText.Top = 10;
        FirstText.Left = 0;
        FirstText.Height = 50;
        FirstText.Width = 210;
        this.Controls.Add(FirstText);
        //Declare, properties and call a TextBox

        SecondText = new TextBox();
        SecondText.Text = $"";
        SecondText.Top = 50;
        SecondText.Left = 0;
        SecondText.Height = 50;
        SecondText.Width = 210;
        this.Controls.Add(SecondText);
        //Declare, properties and call a TextBox

        ThirdText = new TextBox();
        ThirdText.Text = $"0";
        ThirdText.Top = 100;
        ThirdText.Left = 0;
        ThirdText.Height = 50;
        ThirdText.Width = 210;
        this.Controls.Add(ThirdText);
        //Declare, properties and call a TextBox

        InitializeComponent();
        this.StartPosition = FormStartPosition.Manual;
        this.Location = new Point(-5, 0);
    }
    [STAThread]
    static void Main()
    {
        Application.Run(new MyButtonClass());
        //starting objects of class MyButtonClass
    }
    void PlusButton(object sender, EventArgs e)
    {

        if (v == 0)
        {
            SecondText.Text = "+";
            v = 1;
        }
        else if (v == 1)
        {

            n = double.Parse(FirstText.Text);
            k = double.Parse(ThirdText.Text);
            if (SecondText.Text == "+")
            {
                res = n + k;
            }
            else if (SecondText.Text == "-")
            {
                res = n - k;
            }
            else if (SecondText.Text == "x")
            {
                res = n * k;
            }
            else if (SecondText.Text == "/")
            {
                res = n / k;
            }
            string r = Convert.ToString(res);
            FirstText.Text = r;
            SecondText.Text = "+";
            ThirdText.Text = "0";
            v = 1;
        }
    }
    public class FilteredTextBox : TextBox
    {
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            if (e.KeyChar == '+')
            {
                Plus.PerformClick();
                // здесь ошибка
            }
            base.OnKeyPress(e);
        }
    }
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Timofeev, 2015-10-11
@webinar

why ajax? jquery to help you. Just after loading the page, add them to the menu and that's it.

A
Alex, 2015-10-11
@Kozack

Like this
on the client:

jQuery.getJSON(alaxMenu.URL, alaxMenu.params, function(resp) {
  if (resp.success === true) {
    jQuery('menu').append(resp.data);
  }
});

in function.php
wp_localize_script('views-counter', 'alaxMenu', array(
  'url'		=> admin_url('admin-ajax.php'),
  'params'	=> array(
    'action'	=> 'ajax_menu',
    '_ajax_nonce'	=> wp_create_nonce('ajax_menu_nonce'),
  )
));


function get_ajax_menu( $post_object ) {
  check_ajax_referer('ajax_menu_nonce');
  wp_send_json_success(wp_nav_menu( array(
    'theme_location'	=> 'ajax_load',
    'container'			=> false,
    'echo'				=> false,
    'items_wrap'		=> false
  ) ));
}


add_action('wp_ajax_get_ajax_menu', 'get_ajax_menu');
add_action('wp_ajax_nopriv_get_ajax_menu', 'get_ajax_menu');

V
Vladimir Korotenko, 2020-09-16
@NikitaSova

Do you fundamentally not read the documentation?
https://docs.microsoft.com/ru-ru/dotnet/csharp/lan...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question