0

我在 tablelayoutpanel 单元格中有一个 Class(Conatiner) 对象。我想访问该特定字段中的文本字段。如何在单击按钮时获取值?

我想使用 Channel 以及 X 和 Y 值访问 1 2 3 。但我不知道 tableLayoutPanel 中的数字对象

这是我到目前为止写的代码

private void masterTab1_SaveButton_Click(object sender, EventArgs e)
{

   var colWidths = this.MatrixPanel.GetColumnWidths();
   var rowHeights = this.MatrixPanel.GetRowHeights();
   int col = -1, row = -1;
   int offset = 0;
   for (int iRow = 0; iRow < this.MatrixPanel.RowCount; ++iRow)
   {
       offset += rowHeights[iRow];
       row = iRow;
       for (int iCol = 0; iCol < this.MatrixPanel.ColumnCount; ++iCol)
       {
           offset += colWidths[iCol];
           col = iCol;

           var myCellControl = MatrixPanel.GetControlFromPosition(col, row);
           if (myCellControl is Container)
           {
              Adapter.insertposition(RackID, row, col, //Want the Channel Value  , "Ready");
           }
       }
   }
}

在此处输入图像描述

4

1 回答 1

0

如果您的“容器”类设置正确/具有获取所需信息所需的所有属性或控件,那么我相信您正在寻找的是:

if (myCellControl is Container)
{
   Container tmp = myCellControl as Container;
   //after this point, you can reference the controls/properties of your
   //Container class/control using tmp... see example below as i do not know
   //what your Container control exposes as far as properties are concerned.
   Adapter.insertposition(RackID, row, col, tmp.ChannelValue, "Ready");
}
于 2014-03-19T14:29:48.773 回答