예, 버튼 또는 객체의 배열을 만드는 것은 문제가되지 않습니다. Visual Studio 디자이너에서는 볼 수 없지만 정상적으로 작동합니다.
오래전에 나는 계산기 응용 프로그램을위한 UI를 만들기 위해 2 차원 배열의 버튼 배열을 사용했습니다. HP-15C를 오랫동안 사용해 왔지만 놓쳤습니다.
는 배열 방식은 괜찮 았는데.
Button[] numberButtons=new Button[] { btn0, btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9, btnDecimalPt};
Button[] operationButtons=new Button[] { btnDiv, btnMult, btnSubtract, btnAdd };
foreach (var b in numberButtons)
b.Click += new System.EventHandler(this.Number_Click);
foreach (var b in operationButtons)
b.Click += new System.EventHandler(this.Operation_Click);
// etc
Button[][] allButtons=
{
new Button[] {btnSqrt, btnExp, btn10x, btnPow,btnMultInverse, btnCHS, null, null, null, null},
new Button[] {btnN, btnInterest, btnPMT, btnPV, btnFV, null, btn7, btn8, btn9, btnDiv},
new Button[] {btnLn, btnLog, btnSine, btnCosine, btnTangent, btnPi, btn4, btn5, btn6, btnMult},
new Button[] {btnRoll, btnSwap, btnCLRfin, btnCLX, btnCLR, btnEnter, btn1, btn2, btn3, btnSubtract},
new Button[] {btnInt, btnFrac, btnFix, btnStore, btnRecall, null, btn0, btnDecimalPt, btnNotUsed, btnAdd}
};
// programmatically set the location
int col,row;
for(row=0; row < allButtons.Length; row++)
{
Button[] ButtonCol= allButtons[row];
for (col=0; col < ButtonCol.Length; col++)
{
if (ButtonCol[col]!=null)
{
ButtonCol[col].TabIndex = col + (row * allButtons.Length) +1;
ButtonCol[col].Font = font1;
ButtonCol[col].BackColor = System.Drawing.SystemColors.ControlDark;
ButtonCol[col].Size=new System.Drawing.Size(stdButtonWidth, stdButtonHeight);
ButtonCol[col].Location=new Point(startX + (col * stdButtonWidth),
startY + (row * stdButtonHeight)) ;
}
}
}
질문과는 완전히 관련이 없지만 조금만 앞을 내다 보시면 http : //www.devexpress를보실 수 있습니다.com/Products/NET/Controls/WinForms/Scheduler /는 자신의 글을 작성하는 대신 달력 플래너로 사용하기 때문에 적은 노력으로 더 많은 것을 얻을 수 있습니다. – RC1140
+1 스토커 : 스위트) 어디서 좋은 결과를 얻을 수 있습니다. 충분히 추천 할 수 없었습니다. –