コード例 #1
0
ファイル: Form1.cs プロジェクト: Tejas8118/ModbusCodeTest
        // Function code changed event
        public void SelectindechangedfunctionCode(object sender, EventArgs e)
        {
            _functionCode = comboBoxFunctionCode.SelectedItem.ToString().Split(' ')[0];
            switch (comboBoxFunctionCode.SelectedIndex)
            {
            case 0:

                _datatype = "LED";
                groupBoxDatatype.Enabled         = false;
                groupBoxFormat.Enabled           = false;
                buttonWriteMultiRegister.Enabled = true;
                buttonWriteMultiRegister.Enabled = true;
                break;

            case 1:
                _functionCode                    = "2";
                _datatype                        = "LED";
                groupBoxDatatype.Enabled         = false;
                groupBoxFormat.Enabled           = false;
                buttonWriteMultiRegister.Enabled = false;

                break;

            case 2:
                groupBoxDatatype.Enabled = true;
                groupBoxFormat.Enabled   = true;

                if (_datatype.Equals("LED"))
                {
                    _datatype = "Float";
                    groupBoxDatatype.Enabled     = true;
                    comboBoxFormat.SelectedIndex = 1;
                }
                buttonWriteMultiRegister.Enabled = true;
                break;

            case 3:
                groupBoxDatatype.Enabled         = true;
                groupBoxFormat.Enabled           = true;
                buttonWriteMultiRegister.Enabled = false;

                if (_datatype.Equals("LED"))
                {
                    _datatype = "Float";
                    comboBoxDatatype.SelectedIndex = 4;
                    comboBoxFormat.SelectedIndex   = 1;
                }
                break;
            }
            formBaseDataTable.changeFunctionCode(_functionCode);
            formBaseDataTable.changeDataType(_datatype);

            formBaseDataTable.UpdateData();
        }