others - C# 如何从多个文本框中获取值?

我有一个表单,它有很多文本框供用户输入数据,

以下是C#中的一些代码:


// this is the procedure i want to use the value in


public static save()


{


 MessageBox.Show(trackBoxString);


}



// the event handler. trackBoxString is a public static string so that I could access it from different procedures


private void trackBox_TextChanged(object sender, EventArgs e)


{


 trackBoxString = trackBox.Text;


}



这将打开一个空白的消息框

public static raceBoxString = "" ; public static trackBoxString = "" ;


 static void saveSetup()


 {


 try


 {


 string server ="localhost";


 string database ="*****";


 string uid ="""""""";


 string password =""""""";


 MySqlConnection connection;


 string connectionString ="SERVER=" + server +";" +"DATABASE=" + database +";" +"UID=" + uid +";" +"PASSWORD=" + password;


 connection = new MySqlConnection(connectionString);


 connection.Open();


 connection.Close();



 MessageBox.Show(trackBoxString);



 }


 catch (MySqlException ex)


 {


 MessageBox.Show(ex.ToString());


 }



 }



private void raceBox_TextChanged(object sender , EventArgs e) { raceBoxString = raceBox.Text ; }


 private void trackBox_TextChanged(object sender, EventArgs e)


 {


 trackBoxString = trackBox.Text;


 }



时间:

错误是;


An object reference is required for the non-static field, method, or property 



...