C#Combox.text字符串始终在Timer tick函数中显示空字符串

时间:2017-07-19 18:29:27

标签: c#

我有一个应用程序,其中combox文本用数据填充,我有两个计时器函数来读取combox文本内容,一个计时器工作正常,但另一次总是显示combox内容总是空字符串。我想知道哪里出错了

private void AddNewDataToSystemButton_Click(object sender, EventArgs e)
    {

        if (tbAddTrainTrainID.Text != "" && tbAddTrainRegionID.Text != "" && tbAddTrainSegmentID.Text != "")
        {
            bool isTrainAdded = CommonStore.TrainSimMainDatabase.AddNewTrainInToSystem(Convert.ToInt32(tbAddTrainTrainID.Text),
                Convert.ToByte(tbAddTrainRegionID.Text), Convert.ToByte(tbAddTrainSegmentID.Text));

            CommonStore.TrainSimMainDatabase.InitializingTrainCollection[Convert.ToInt32(tbAddTrainTrainID.Text)].VehicleList.IsManualTrain = false;

            if (isTrainAdded)
            {
                cbTrainList.Items.Add(tbAddTrainTrainID.Text);
                cbRemoveTrainID.Items.Add(tbAddTrainTrainID.Text);

            }
            else
            {
                TrainChangeRequestResponse.Text = "Train already exists in the system.";
            }
        }
    }


private void Timer1_Tick(object sender, EventArgs e)
    {
        if (CommonStore.TrainSimMainDatabase != null)
        {

            if (CommonStore.TrainSimMainDatabase.InitializingTrainCollection.Count > 0 && cbTrainList.Text != "")
            {
                // huge code
            }
}  

 }

public void VATCTimer_Tick(object sender, EventArgs e)
    {
        if (cbTrainList.Text != "")
        {


\\ huge code

0 个答案:

没有答案