- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有 2 个表单,分别是 BillingForm(父表单)和 SearchProduct(子表单)。
BillingForm代码
private void textBoxProductNo_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode==Keys.F9)
{
using(SearchProduct sp=new SearchProduct)
{
sp.ShowDialog(this);
}
}
}
public void updatedText(string fromChildForm)
{
textBoxProduct.text=fromChildForm;
}
SearchProduct表单代码(子表单)
private void dataGridView1_KeyDown(object sender,KeyEventArgs e)
{
if(e.KeyCode==Keys.Enter)
{
BillingForm bf=(BillingForm)this.Owner; //Error appear here
bf.updatedText("Hello World");
this.close();
}
}
我收到一条错误消息。
BillingSoftware.exe 中出现类型为“System.InvalidCastException”的未处理异常
附加信息:无法将“BillingForm.MDIParent”类型的对象转换为类型“BillingForm.BillingForm”
最佳答案
尝试将父级传递给构造函数并在变量中使用它
using(SearchProduct sp = new SearchProduct(this))
{
sp.ShowDialog(this);
}
//In SearchProduct class
public BillingForm MyParent {get; private set;}
public SearchProduct(BillingForm parent)
{
this.MyParent = parent;
}
private void dataGridView1_KeyDown(object sender,KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
BillingForm bf = this.MyParent;
bf.updatedText("Hello World");
this.close();
}
}
关于c# - 如何将值从子窗体传递到父窗体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38405030/
对于一个科学实验,我写了一个turtle.py ,它会打开一个 800x480 的窗口并绘制一个缓慢增长的黑点。 turtle.py以 C:\Users\kaza>python C:\Users\ka
我开发了一个 swing 应用程序,但每次运行应用程序时都会打开一个新窗口。我希望如果一个窗口已经打开,则其他窗口不允许打开。 最佳答案 Here是一个 Java 单一应用实例的例子: A singl
有没有办法检测主进程中 Electron 的结构? process.platform 似乎也在 x64 机器上返回 win32,我没有在文档中找到任何获取架构的选项。 最佳答案 你试过 process
public short[] HanningWindow(short[] signal_in ,int pos ,int size) { for (int i= pos; i < pos+si
我有一个具有这些属性的 Electron 窗口: mainWindow = new BrowserWindow({ width: 800, height: 600, title: "Aqu
我有一个 Ubuntu 工作站,我正在尝试引导一个 Windows 节点。 Windows 节点在端口 2222 上打开了 ssh。我一直在关注 http://docs.opscode.com/plu
我是一名优秀的程序员,十分优秀!