-
Re: DataCombo inside DataGrid
"Simon Chen" <sales@yongtai.com> wrote:
>
>I would like to create a DataCombo inside the DataGrid using Visual Basic
>6.0. That means when I click the button of DataGrid Column, a DataCombo
will
>be activated and I can use the data of this DataCombo to edit the value
of
>the DataGrid Column. Can you help me?
>
>Thank you very much in advance for your help.
>
>
>This is a code sample that uses a listbox inside a datagrid
use two ado data controls a list box and a data grid
Option Explicit
Dim RowValue
Dim cn As New ADODB.Connection
Dim rsOrders As New ADODB.Recordset
Dim rsCustomers As New ADODB.Recordset
Private Sub DataList1_Click()
DataGrid1.Text = DataList1.Text
DataList1.Visible = False
End Sub
Private Sub DataList1_LostFocus()
DataList1.Visible = False
End Sub
Private Sub DataGrid1_Scroll(Cancel As Integer)
DataList1.Visible = False
End Sub
Private Sub Form_Load()
cn.Open "Provider=Microsoft.Jet.OLEDB.3.51;" & _
"Data Source=NWind.mdb;"
With rsOrders
.ActiveConnection = cn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open "Select * From Orders"
End With
Set Adodc1.Recordset = rsOrders
With rsCustomers
.ActiveConnection = cn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.Open "Select CustomerID From Customers ORDER BY CustomerID"
End With
Set Adodc2.Recordset = rsCustomers
DataList1.Visible = False
DataGrid1.Columns(1).Button = True
End Sub
Private Sub DataGrid1_ButtonClick(ByVal ColIndex As Integer)
If ColIndex = 1 Then
DataList1.Top = DataGrid1.Top + DataGrid1.RowTop(DataGrid1.Row) + DataGrid1.RowHeight
DataList1.Left = DataGrid1.Left + DataGrid1.Columns(ColIndex).Left
' Width and Height properties can be set a design time
' The width of the list does not have to be the same as the width of
the grid column
DataList1.Width = DataGrid1.Columns("CustomerID").Width
DataList1.Height = 1440
DataList1.Visible = Not DataList1.Visible
If DataList1.Visible Then
DataList1.Text = DataGrid1.Text
DataList1.ZOrder ' make sure the list is on top of the grid
End If
End If
End Sub
Private Sub DataGrid1_Click()
DataList1.Visible = False
End Sub
Private Sub DBGrid1_ButtonClick(ByVal ColIndex As Integer)
End Sub
Private Sub DBGrid1_Click()
End Sub
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks