用户的C#表单问题 [英] c# form problem with user
本文介绍了用户的C#表单问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好!首先,抱歉我的英语不好.我有三个类,需要将var userId保存在表单中.头等舱是:
Hello! First Sorry for my bad English. I have three classes and I need to save my var userId in my form . First Class is:
private void buttonOk_Click(object sender, EventArgs e)
{
UserEntity user = new UserEntity(textBoxUsername.Text,textBoxPassword.Text);
if (user.getUser()) {
MainPanel mp = new MainPanel();
mp.User = user;
mp.Show();
}
单击按钮后,我们进入第二类:
When the button is clicked we go to Second class:
private void ProfitPanelButton_Click(object sender, EventArgs e)
{
UserEntity user = new UserEntity();
if (user.getUser())
{
ProfitPanel pp = new ProfitPanel();
pp.User = user;
pp.Show();
}
else
{
MessageBox.Show("ERROR");
}
}
当我们单击ProfitPanelButton时,转到利润并将利润插入DB.
使用代码从第一个按钮直接转到第三个按钮没有任何问题:
When We clicked ProfitPanelButton go to profit and insert Profit into DB .
I don''t have any problem with going from 1st button directly to 3rd with code :
private void buttonOk_Click(object sender, EventArgs e)
{
UserEntity user = new UserEntity(textBoxUsername.Text,textBoxPassword.Text);
if (user.getUser()) {
ProfitPanel pp = new ProfitPanel();
pp.User = user;
pp.Show();
}
}
您能帮我解决这个问题还是给我一些想法.谢谢.
Can you help me to fix this problem or give me some idea. Thanks.
推荐答案
这里没有明确的问题,但是如果您调用Show(显示),它将创建无模式对话框,如果您使用局部变量来执行此操作,立即失去对该对象的引用,这将阻止您与该对象进行交互.将其设置为成员变量,然后编辑您的问题,以使您清楚地提出问题.
There''s no clear question here, but if you call Show, which creates a modeless dialog, if you do it with a local variable, you lose your reference to that object right away, which stops you from interacting with it. Make it a member variable, then edit your question so you ask something clearly.
这篇关于用户的C#表单问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文