Пример #1
0
        private void myEditRow(int iRow)
        {
            tParam param = paramList[iRow];

            // if already editing, close previous edit
            if (curInputIndex >= 0)
            {
                myEditClose();
            }
            curInputIndex    = iRow;
            tbEdit.MaxLength = param.maxLengthValue;
            tbEdit.Size      = param.lblValue.Size;
            tbEdit.Margin    = param.lblValue.Margin;
            tbEdit.Text      = "";
            if (param.input == cInputType.NUMBER)
            {
                if (param.value == Configuration.noDataStr)
                {
                    tbEdit.Text = "";
                }
                else
                {
                    tbEdit.Text = param.value;
                }
            }
            else
            {
                if (param.value == Configuration.noDataStr)
                {
                    tbEdit.Text = "";
                }
                else
                {
                    tbEdit.Text = param.lblValue.Text;
                }
            }
            // send label to last row, first column
            param.lblValue.Visible = false;
            TableLayoutPanel1.SetCellPosition(param.lblValue, new TableLayoutPanelCellPosition(0, TableLayoutPanel1.RowCount - 1));
            // position edit control (in second column) in current row
            TableLayoutPanel1.SetRow(tbEdit, curInputIndex);
            //tbEdit.Text = tbEdit.Location.X.ToString & ";" & tbEdit.Location.Y.ToString & " " & _
            //              param.lblValue.Location.X.ToString & ";" & param.lblValue.Location.Y.ToString
            tbEdit.Visible = true;
            tbEdit.Focus();
            tbEdit.SelectionLength = tbEdit.TextLength;
            tbEdit.BringToFront();
        }
Пример #2
0
 private void myEditClose()
 {
     if (curInputIndex != -1)
     {
         tParam param = paramList[curInputIndex];
         if (param.value != tbEdit.Text && !(param.value == Configuration.noDataStr && tbEdit.Text == ""))
         {
             setValue(param.paramName, tbEdit.Text);
             if (NewValueEvent != null)
             {
                 NewValueEvent(param.paramName, param.value);
             }
         }
         // send edit control to the last row (same second column)
         tbEdit.Visible = false;
         TableLayoutPanel1.SetRow(tbEdit, TableLayoutPanel1.RowCount - 1);
         // re-position label to the editin row, second column
         TableLayoutPanel1.SetCellPosition(param.lblValue, new TableLayoutPanelCellPosition(1, curInputIndex));
         param.lblValue.Visible = true;
         curInputIndex          = -1;
     }
 }