且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在用户控件中为标签添加值?

更新时间:2022-06-02 19:58:04

SELECT name FROM registration_data WHERE email ='{login }',conn);
var reader = cmd.ExecuteReader();
while(reader.Read())labelWelcome.Text = reader [0] .ToString();
}

最后
{
conn.Close();
}
}
}
"SELECT name FROM registration_data WHERE email = '{login}'", conn); var reader = cmd.ExecuteReader(); while (reader.Read()) labelWelcome.Text = reader[0].ToString(); } finally { conn.Close(); } } }


不要 - 将用户控件的内部工作暴露给外界。

相反,请看这里:传输信息两种表格之间,第1部分:父母与子女 [ ^ ] - 它专注于表单,但控件的原则(甚至代码)完全相同(因为Form派生自Control)
Don't - that exposes the internal workings of the user control to the outside world.
Instead, see here: Transferring information between two forms, Part 1: Parent to Child[^] - it focusses on forms, but the principles (and even the code) are exactly the same for controls (because Form is derived from Control)