English 中文(简体)
用Button在VSCode的点击来改变Label案文
原标题:Changing Label text with Button click in VSCode
  • 时间:2024-01-21 00:34:36
  •  标签:
  • c#
  • winforms

因此,我一直在为我选择的语言制作字典和用正文。 我不了解最佳环境,但更想知道,在这种情况下,什么都不会引起担忧。

因此,我得以创立一个全球调查组,并拥有所有标签和托邦以及我用来储存某些数据的第二份档案。 在各小组之间发生变化时,我已接过纽子。 但是,我面临的问题是,在我登州时,2次我无法得到更改标签的文本。

现行法典:

using System.Windows.Forms;
using System.Drawing;
using System.Security.Cryptography.X509Certificates;
using System.CodeDom;
using System.Drawing.Text;

//Most of the following code works and does produce the window
//Having to work on converting from the Java coud that works to C#
//This is now working and continueing to build it up.

namespace unchained{
    public static class Program{
        public static void Main(String [] args){
            Form window = new();
            ...

            Button style = new();
            style.Text = "Style";
            style.Location = new Point(25, 25);
            style.BackColor = Color.FromArgb(255, 255, 255);
            style.Click += (sender, e) => roleSelected(sender, e, "style");
            Label selectStyle = new();
            selectStyle.Text = charSheet.style;
            selectStyle.Location = new Point(25,325);
            selectStyle.ForeColor = Color.FromArgb(255, 255, 255);
            
            ...
            
            window.Width = 800;
            window.Height = 600;
            window.Controls.Add(style);
            window.Controls.Add(selectStyle);
            Application.Run(window);

            void roleSelected(object sender, EventArgs e, string value){
                    Console.WriteLine(value);
                    newSheet.style = value;
                    selectStyle.Text = value;
                    Console.WriteLine(newSheet.style);
            }      
        }
    }
}

Console记录仪将检查价值正在下降,并检查为临时储存而制造的第二类。 我知道,数据没有问题,但标签没有更新。 我所看到的其他一些答复是,在标签上使用复读,但我无法查阅标签,因为标签不是初步的。 但是,当我这样做时,我会遇到其他问题。

因此,我看看一下我怎么会错。

感谢。

问题回答

Was able to solve it and found a better way to handle the logic then I originally thought.

我决定获得被点击的标签的价值。 当时,Wghich I得以派人来证实我曾经说过的话,我从那以后就能够贴上Name的标签。 案文 = 序号

            Button btn2 = sender as Button;
            string r = btn2.Text;
            newSheet.someVariable = r;
            labelIWantedChanged.Text = newSheet.someVariable;

这种方法在被点击的纽顿语中使用。





相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签