タイムアウトセッションとして機能するメインアプリケーション内にタイマー機能があります。しかし、私は、タイマーの間隔とサブフォームを介してオンとオフを切り替える機能を変更したいが、設定を変更するために別のフォーム内のタイマー機能要素を使用することはできません。以下は私のコードスニペットです。任意のヒントや例をいただければ幸いです。メインフォームのサブフォームからタイマー設定を変更する方法C#
試み: メインフォーム
private void Booyaa_Load(object sender, EventArgs e)
{
BooyaaTimer.Interval = 45 * 60 * 1000); // 45 mins
BooyaaTimer.Tick += new EventHandler(BooyaaTimer_Tick);
BooyaaTimer.Start();
if (!Properties.Settings.Default.SettingShutdown)
{
MessageBox.Show("Not properly shut down");
GetPass pass = new GetPass();
DialogResult result = pass.ShowDialog();
if (result == DialogResult.OK) {
Properties.Settings.Default.SettingShutdown = true;
Properties.Settings.Default.Save();
}
else
{
Close();
}
}
private void BooyaaTimer_Tick(object sender, EventArgs e)
{
MessageBox.Show("TIME IS UP");
GetPass pass = new GetPass();
DialogResult result = pass.ShowDialog();
if (result == DialogResult.OK)
{
Show();
Properties.Settings.Default.SettingShutdown = true;
Properties.Settings.Default.Save();
}
else
{
BooyaaTimer.Start();
Properties.Settings.Default.SettingShutdown = false;
Properties.Settings.Default.Save();
Hide();
}
}
タイマーコントロール、私は推測を作るつもりです
public object BooyaaTimer { get; private set; }
private void btn_confirm_Click(object sender, EventArgs e)
{
BooyaaTimer.Interval = Int32.Parse(textBox1.Text); // gives error on interval
}
'btn_confirm_Click'コードが不完全であるに作成されます。 –
@ JohnnyMopp私の主張は、メインフォームからインターバル機能を使用することができないため、私はそれを続行できないということです。 –
「タイマー」とは何ですか?そしてなぜ 'BooyaaTimer'が' System.Windows.Forms.Timer'オブジェクトではなく 'object'であるのでしょうか? [mcve]の作成方法をお読みください。 –