我在Form1-Class的Method中有这段代码:
public void logUserActivity(string Date, string Username, string IP, TierType Status, string Version, bool CPUSpoof, bool TamperedFile)
{
string Note = "", TextStatus = "";
if (TamperedFile && CPUSpoof)
Note = "TamperedFile & CPU Spoofed";
else if (CPUSpoof)
Note = "CPU Spoofed";
else if (TamperedFile)
Note = "Tampered File";
TextStatus = getTierTypeStatus(Status);
this.userActivity.Rows.Add(Date, Username, IP, TextStatus, Version, Note);
//this.userActivity is the DataGridView
}
现在我有第二个类,我们称之为Class 2.在这个类中我声明了这个:
Form1 main = new Form1();
现在我从该类中的某个地方调用logUserActivity,例如:
main.logUserActivity(string.Format("{0}.{1}.{2} - {3}:{2}:{1}", DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year,
DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second), username, clientIP, status, version, cpuSpoof, (xexState == 2));
参数值是正确的,它在logUserActivity Void中,但是行不会添加。我试过调用它,但它仍然无法正常工作。如果我从Form1中的某个地方调用this.logUserActivity()它可以工作,但是当我从其他类调用它时。 关于这个人的任何想法!?