Quantcast
Channel: OKWAVE 最新質問(Visual Basic/257)【本日】
Viewing all articles
Browse latest Browse all 7264

VB2010でのコントロール多次元配列について

$
0
0
教えてください。 実行中にコントロールを生成したいのですが、 Public Class Form1  Private myTxt(,) As System.Windows.Forms.TextBox  Me.myTxt = New System.Windows.Forms.TextBox(59, 2) {}  Dim i As Integer  Dim j As Integer  Dim h As Integer  Dim p As Integer  h = 10  p = 100  For i = 0 To Me.myTxt.GetLength(0) - 1   For j = 0 To Me.myTxt.GetLength(1) - 1    Me.myTxt(i, j) = New System.Windows.Forms.TextBox    Me.myTxt(i, j).Name = "myTxt" + i.ToString() + j.ToString()    Me.myTxt(i, j).Size = New Size(100, 30)    Me.myTxt(i, j).Location = New Point(p, h)    p = p + 100   Next j   h = h + 30  Next i  Me.myPnl.Controls.AddRange(Me.myTxt) と書くと最後の行が波線になり、 “型 'System.Windows.Forms.TextBox の 2 次元配列' の値を 'System.Windows.Forms.Control' に変換できません。”とエラーになります。 これはAddRangeは多次元配列に使用できないということなのでしょうか? 色々検索してみましたが、コントロールの生成に関する多次元配列が見つけられずに 困っていました。 最後のAddRange(Me.myTxt)をAdd(Me.myTxt(i,j))などと変えたりしても別のエラーになり、 基本的に間違っている気がしますがどこだかがわかりません。 詳しい方、宜しくお願い致します。

Viewing all articles
Browse latest Browse all 7264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>