|
-
March 23rd, 2001, 12:32 AM
#1
How to create a DataGrid on running time ?
Hi, everyone :
If I want create a Label on running time .
I can code like under :
Dim Label1 as Label
set Label1 = Controls.Add("VB.Label", "Label1")
but If I want create a "DataGrid" on running time ,
Can you tell me how to code ?
Thanks very much
-
March 23rd, 2001, 11:37 AM
#2
Re: How to create a DataGrid on running time ?
private Sub Form_Load()
Dim DBG as DataGrid
set DBG = Controls.Add("MSDATAGRIDLIB.datagrid", "DbGrid")
DBG.Move 0, 0, 1000, 10000
DBG.Visible = true
End Sub
John G
-
March 23rd, 2001, 11:47 AM
#3
Re: How to create a DataGrid on running time ?
Do the same as you do with label. Some special requirements:
1.Add a reference to the control through Components
2. If you did not place any grid at design time, then go to project properties, and uncheck "Remove information about unused ActiveX controls"
3. Place Grid on your form just to find how it's called - for Microsoft DataBound Grid Control it's DBGrid.
4.Run RegEdit and make search for DBGrid.
5. When it's found, open ProgID hive and read Value - for our case it's "MSDBGrid.DBGrid"
Now do the same as for label, create it, set properties, make it visible and so on.
Example of code:
private Sub Command1_Click()
Dim Label1 as Label
Dim Grid as DBGrid
set Label1 = Controls.Add("VB.Label", "Label1")
set Grid = Controls.Add("MSDBGrid.DBGrid", "Grid1")
With Label1
.Visible = true
.Left = 100
.Top = 100
.Width = 500
.Caption = "Label"
End With
With Grid
.Visible = true
.Width = 3500
.Height = 1500
End With
End Sub
HTH
Vlad
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|