(急) Visual Basic2005 如何自動新增TextBox 那類型東西?

2008-04-06 9:03 pm
我在Visual Basic 2005中, 已連結DATABASE,
但是不想用內置的DataGridView來看DATA,
想使用TextBox那類型的東西來看,
但是, TextBox那類型的東西不能自動新增,
每次只可以看第一個DATA記綠,
我應如何做才能使TextBox 那類型自動新增,
來看數十個DATA 記綠呢?

回答 (2)

2008-04-08 9:42 am
✔ 最佳答案
Add a Panel Control named Panel1 to hold the textboxes.
Suppose you have a DataTable dat

count = dat.Rows.Count
For i = 0 To count - 1
Dim txt As TextBox = New TextBox()
txt.Text = dat(i)(column_variable)
Panel1.Controls.Add(txt)
txt.Top = i * 25
If i = 9 Then Exit For
Next

This is a simple example. If you want to display record 11-20, 21-30, etc, you need to control the paging by setting the start number of the For Loop.
2008-04-07 5:32 am
??什麽那類型自動新增?
不是
Dim x As TextBox = new TextBox
之類的東西吧


收錄日期: 2021-04-25 20:32:58
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20080406000051KK01148

檢視 Wayback Machine 備份