在WinForms中,如果将方法名称(例如button1_Click)更改为其他名称,则它不再起作用.
我发现这很奇怪,因为在控制台应用程序中,据我记得你可以根据需要命名方法.我正在努力了解发生了什么.
如何更改这些方法的名称(例如button1_Click)?
我有一个在form1中创建的textbox7,但我想以另一种形式访问它,表单2所以我将其修饰符更改为public
当我进入form2时,我希望它执行以下操作
Form1.textBox7.ReadOnly = true;
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误
错误1非静态字段,方法或属性'WindowsFormsApplication1.Form1.textBox7'需要对象引用C:\ Users\Admin\Google Drive\AdminhomeGD\ztese\zprograma\WindowsFormsApplication1\WindowsFormsApplication1\formOpConfig.cs 73 46 WindowsFormsApplication1
我不知道出了什么问题
编辑:
我正在尝试在form1(名为Form1)上使用以下内容:
public Boolean gammamanual
{
get { return textBox7.ReadOnly; }
set { textBox7.ReadOnly = value; }
}
Run Code Online (Sandbox Code Playgroud)
而在form2上(名为formOpConfig):
namespace WindowsFormsApplication1
{
public partial class formOpConfig : Form
{
public formOpConfig(Form1 opener)
{
// this is a constructor
this.Opener = opener;
}
private Form1 Opener { get; set; }
public formOpConfig() { // initialization and stuff }
private void buttonExit_Click (object sender, EventArgs e)
{
if (checkBox3.Checked …Run Code Online (Sandbox Code Playgroud) 您好我正在尝试将大字符串保存到文件中
string _ULSWcalc = "1.35 * " + _Gd + "+ 1.5 * " + _Wd + "1.5 * " + _Qd " * 0.8";
File.WriteAllLines("C:\\aab.txt", _ULSWcalc);
Run Code Online (Sandbox Code Playgroud)
_Gd _Wd并且_Qd都是变量而且是"".它们都很明确,程序无需File.WriteAllLines线路
但如果我放置它我得到这2错误
错误2参数2:无法从'string'转换为'System.Collections.Generic.IEnumerable'
错误1'System.IO.File.WriteAllLines(string,System.Collections.Generic.IEnumerable)'的最佳重载方法匹配有一些无效的参数