阅读后台工作人员中的文本框 [英] Read Text box in background worker

查看:67
本文介绍了阅读后台工作人员中的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi,

如何从后台工作人员阅读文本框?

How do i read text box from background worker?

我尝试执行以下操作,但是我想返回文本框内容并将其存储在名为TextName的变量中.

i tried doing the below, but i want to return the text box content and store in a variable called TextName.

无效backgroundWorker1_DoWork(System :: Object ^发送者,System :: ComponentModel :: DoWorkEventArgs ^ e){

Void backgroundWorker1_DoWork(System::Object^  sender, System::ComponentModel::DoWorkEventArgs^  e) {

LPCTSTR TextName;

LPCTSTR TextName;

MyInvoke ^ update1 = gcnew MyInvoke(this,& Form1 :: update1);

MyInvoke^ update1 = gcnew MyInvoke(this, &Form1::update1);

}

  void update1(){

String ^ text = this-> textbox1-> Text;
}

 void update1(){

String^ text=this->textbox1->Text;
}

有什么想法吗?

如何从update1()返回?

how to return from the update1()?

推荐答案

如果您认为不能直接从中访问 Text 线程,然后尝试以下方法:

If you believe that Text cannot be accessed directly from threads, then try this:

delegate String ^ MyInvoke2();

String ^ update2()
{
    return textBox1->Text;
}

用法:

auto i = gcnew MyInvoke2( this, &Form1::update2 );
String ^ text = i();


这篇关于阅读后台工作人员中的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆