English 中文(简体)
无控制 视窗 与Windows Form相同文档中的另一种方法的形式物体
原标题:Cannot control Windows Form objects from another method in the same file as the Windows Form
  • 时间:2010-07-30 16:21:02
  •  标签:
  • c#

我最近开始在电网(C#)开展大型项目,我在守则中遇到了一些ug。 最后,我已经跟踪了这一问题,但是,如果可能的话,我希望在确定其位置方面提供援助。 我经常必须使用一种称为“更新倡议”的方法,这将是很大的,但其中任何守则都不会影响《倡议》! 这种方法是公开的,而不是静态的(尽管我已经静态地尝试过这种方法,并用标语提及同样的效果),并且与“Windows Form I”试图更新的同一档案中。 我已经删除了大多数简化法,我刚刚表明,这是为了表明我的声明。 我只想问,我真的不应该把我混为一谈的一点非常简单。

感谢大家阅读,

Richard

public partial class ScanStatus : Form
{
    public ScanStatus()
    {
        InitializeComponent();

        label3.Enabled = true;                 

        // Some code. When "label3.Enabled = true" is placed here, it works perfectly.
    }

    public void UpdateUI()
    {
        label3.Enabled = true;

        // However, the above "label3.Enabled = true" does absolutely nothing, no exception, nothing.
    }                  
}
最佳回答

修改你的法典,在方法上增加一条:

public void UpdateUI()
{
    label3.Enabled = true;
    this.Show();
} 

如果我的猜测正确,现在请见 2<>m>。 有一个标签。

Nope, 你可以向新经营者提及现有表格。 在你创建表格时,你必须储存这一提法,以便你在晚些时候重新使用。

问题回答

你们必须保证,打电话更新倡议的守则正在使用正确的表格(与你所显示的相同),以便你不会有两种情况,一种是明显的,一种是隐蔽的。

此外,确保《最新倡议》只从“倡议”的炉).中发出(这更是一般性的,因为这会造成错误,而不是根本没有发生)。

如果这无助的话,就把你重新命名更新倡议的守则张贴在后面(如果你重新获得你使用的标语名称)。

你们是否正在经历过广泛的例外? 也许你正在从一个非倡议的线索中更新国际数据。 考虑使用BeginInvoke()





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

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. ...