home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 6 Unleashed…sional Reference Edition) / Visual_Basic_6_Unleashed_Professional_Reference_Edition_Sams_1999.iso / Source / CHAP16 / DataObj.ctl (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-06-11  |  21.8 KB  |  514 lines

  1. VERSION 5.00
  2. Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
  3. Begin VB.UserControl uctDOCtlDataGrid 
  4.    ClientHeight    =   3600
  5.    ClientLeft      =   0
  6.    ClientTop       =   0
  7.    ClientWidth     =   4800
  8.    ScaleHeight     =   3600
  9.    ScaleWidth      =   4800
  10.    Begin VB.ComboBox cmbEdit 
  11.       Appearance      =   0  'Flat
  12.       Height          =   315
  13.       Left            =   480
  14.       Style           =   2  'Dropdown List
  15.       TabIndex        =   1
  16.       Top             =   1320
  17.       Visible         =   0   'False
  18.       Width           =   1000
  19.    End
  20.    Begin MSDataGridLib.DataGrid grdDOCtl 
  21.       Height          =   3400
  22.       Left            =   120
  23.       TabIndex        =   0
  24.       Top             =   120
  25.       Width           =   4600
  26.       _ExtentX        =   8123
  27.       _ExtentY        =   6006
  28.       _Version        =   393216
  29.       HeadLines       =   1
  30.       RowHeight       =   15
  31.       BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  32.          Name            =   "MS Sans Serif"
  33.          Size            =   8.25
  34.          Charset         =   0
  35.          Weight          =   400
  36.          Underline       =   0   'False
  37.          Italic          =   0   'False
  38.          Strikethrough   =   0   'False
  39.       EndProperty
  40.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  41.          Name            =   "MS Sans Serif"
  42.          Size            =   8.25
  43.          Charset         =   0
  44.          Weight          =   400
  45.          Underline       =   0   'False
  46.          Italic          =   0   'False
  47.          Strikethrough   =   0   'False
  48.       EndProperty
  49.       ColumnCount     =   2
  50.       BeginProperty Column00 
  51.          DataField       =   ""
  52.          Caption         =   ""
  53.          BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
  54.             Type            =   0
  55.             Format          =   ""
  56.             HaveTrueFalseNull=   0
  57.             FirstDayOfWeek  =   0
  58.             FirstWeekOfYear =   0
  59.             LCID            =   1033
  60.             SubFormatType   =   0
  61.          EndProperty
  62.       EndProperty
  63.       BeginProperty Column01 
  64.          DataField       =   ""
  65.          Caption         =   ""
  66.          BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
  67.             Type            =   0
  68.             Format          =   ""
  69.             HaveTrueFalseNull=   0
  70.             FirstDayOfWeek  =   0
  71.             FirstWeekOfYear =   0
  72.             LCID            =   1033
  73.             SubFormatType   =   0
  74.          EndProperty
  75.       EndProperty
  76.       SplitCount      =   1
  77.       BeginProperty Split0 
  78.          BeginProperty Column00 
  79.          EndProperty
  80.          BeginProperty Column01 
  81.          EndProperty
  82.       EndProperty
  83.    End
  84. Attribute VB_Name = "uctDOCtlDataGrid"
  85. Attribute VB_GlobalNameSpace = False
  86. Attribute VB_Creatable = True
  87. Attribute VB_PredeclaredId = False
  88. Attribute VB_Exposed = False
  89. Attribute VB_Ext_KEY = "WizardYN" ,"Yes"
  90. Attribute VB_Ext_KEY = "VBProjectName" ,"Project1"
  91. Attribute VB_Ext_KEY = "DEDesignerName" ,"DataEnvironment1"
  92. Attribute VB_Ext_KEY = "ConnectionName" ,"Connection1"
  93. Attribute VB_Ext_KEY = "CommandName" ,"OrderInfo"
  94. Attribute VB_Ext_KEY = "ClassType" ,"User Control"
  95. Attribute VB_Ext_KEY = "DataClassName" ,"rsclsDataObjClass"
  96. Attribute VB_Ext_KEY = "RootName" ,"uctDOCtlDataGrid"
  97. Attribute VB_Ext_KEY = "UserControlType" ,"DataGrid"
  98. '=============================================================
  99. 'Name: uctDOCtlDataGrid (The DataGrid UserControl object)
  100. 'Author: Microsoft Data Object Wizard
  101. 'Date: 06/11/1998 18:39
  102. 'Description: DataGrid UserControl object using a Data Object Wizard RecordSet class as a DataSource class.
  103. 'Comment:
  104. '=============================================================
  105. 'The current datagrid control column
  106. Private mlCurrentCol As Long
  107. 'Prohibits several operations the first time the datagrid control loads.
  108. Private mbFirstTime As Boolean
  109. 'Prohibits showing the listbox control as the datagrid control loads for the first time.
  110. Private mbShowCombo As Boolean
  111. 'Allows the datagrid control to be editable and displays the listbox control on columns with the Foreign Key attributes.
  112. Public GridEditable As Boolean
  113. 'True if an error occurred in the DataSource class.
  114. Private mbClassError As Boolean
  115. 'Create the datagrid control column constants
  116. Private Const ORDERID_COLUMN As Long = 0
  117. Private Const CUSTOMERID_COLUMN As Long = 1
  118. Private Const CUSTOMERSCOMPANYNAME_COLUMN As Long = 2
  119. Private Const ORDERDATE_COLUMN As Long = 3
  120. Private Const PRODUCTID_COLUMN As Long = 4
  121. Private Const UNITPRICE_COLUMN As Long = 5
  122. Private Const QUANTITY_COLUMN As Long = 6
  123. 'Create parameter properties for the Select RecordSet class
  124. 'Create the Foreign Key Parameter properties for the RecordSet classes
  125. 'Use the Data Object Wizard RecordSet class as a DataSource class
  126. Private WithEvents oDataObjClass As rsclsDataObjClass
  127. Attribute oDataObjClass.VB_VarHelpID = -1
  128. 'Set the ManualInitialize property to false to automatically initialize or true to manually inititalize the UserControl object
  129. Public ManualInitialize As Boolean
  130. 'The RecordSet Move event
  131. Public Event MoveComplete(oDataSource As Object)
  132. 'Format the object for the datagrid control Boolean columns
  133. Private oStdDataFormat As StdDataFormat
  134. 'Save the adImmediate property when the user moves off the row.
  135. Public SaveMode As EnumSaveMode
  136. Public Function InitDataObjClass(Optional oDataObjClass0 As Variant) As Object
  137. '=============================================================
  138. 'Name: InitDataObjClass
  139. 'Author: Microsoft Data Object Wizard
  140. 'Date: 06/11/1998 18:39
  141. 'Description: Initializes the datagrid control.
  142. 'Comment:
  143. '=============================================================
  144.     'Set flags to true on load.
  145.     mbFirstTime = True
  146.     mbShowCombo = True
  147.     'Create Format object for the datagrid control Boolean columns
  148.     Set oStdDataFormat = New StdDataFormat
  149.     oStdDataFormat.Type = fmtBoolean
  150.     oStdDataFormat.FalseValue = "False"
  151.     oStdDataFormat.TrueValue = "True"
  152.     On Error GoTo InitDataObjClassErr
  153.     'Reset the DataSource class.
  154.     Set oDataObjClass = Nothing
  155.     'Use the Data Object Wizard RecordSet class as the DataSource class for the datagrid control
  156.     If IsMissing(oDataObjClass0) Then
  157.         'If the DataSource class was not passed as a parameter, create the DataSource class.
  158.         Set oDataObjClass = New rsclsDataObjClass
  159.     Else
  160.         'Use the DataSource class passed as a parameter.
  161.         Set oDataObjClass = oDataObjClass0
  162.     End If
  163.     'Set the RecordSet class Foreign Key parameter properties to the UserControl object values
  164.     'Save the adImmediate property when the user moves off the row.
  165.     oDataObjClass.SaveMode = Me.SaveMode
  166.     'Set the source of data for the datagrid control
  167.     mbClassError = False
  168.     grdDOCtl.DataMember = "ORDERINFO"
  169.     Set grdDOCtl.DataSource = oDataObjClass
  170.     'If there is an error, exit the function.
  171.     If mbClassError Then
  172.         MsgBox "Cannot initialize grid control."
  173.         Exit Function
  174.     End If
  175.     'Allow new records and deletes for the datagrid control
  176.     If GridEditable Then
  177.         grdDOCtl.AllowAddnew = True
  178.         grdDOCtl.AllowDelete = True
  179.         grdDOCtl.AllowUpdate = True
  180.     Else
  181.         grdDOCtl.AllowAddnew = False
  182.         grdDOCtl.AllowDelete = False
  183.         grdDOCtl.AllowUpdate = False
  184.     End If
  185.     'Show both scroll bars for the control.
  186.     grdDOCtl.ScrollBars = dbgboth
  187.     'Since the listbox control height cannot resize, force the same for the datagrid control RowHeight property.
  188.     grdDOCtl.AllowRowSizing = False
  189.     'Set the RowHeight property to make the listbox controls appear in the row of the datagrid control.
  190.     grdDOCtl.RowHeight = 288
  191.     'Hide columns not used in control
  192.     grdDOCtl.Columns(COMPANYNAME_COLUMN).Width = 0
  193.     'Column Headings for the datagrid control
  194.     grdDOCtl.Columns(ORDERID_COLUMN).Caption = "OrderID"
  195.     grdDOCtl.Columns(CUSTOMERID_COLUMN).Caption = "CustomerID"
  196.     grdDOCtl.Columns(CUSTOMERSCOMPANYNAME_COLUMN).Caption = "CompanyName"
  197.     grdDOCtl.Columns(ORDERDATE_COLUMN).Caption = "OrderDate"
  198.     grdDOCtl.Columns(PRODUCTID_COLUMN).Caption = "ProductID"
  199.     grdDOCtl.Columns(UNITPRICE_COLUMN).Caption = "UnitPrice"
  200.     grdDOCtl.Columns(QUANTITY_COLUMN).Caption = "Quantity"
  201.     'Save the current column of the datagrid control
  202.     mlCurrentCol = grdDOCtl.Col
  203.     'Set the Flag to false
  204.     mbFirstTime = False
  205.     'Return the Class object.
  206.     Set InitDataObjClass = oDataObjClass
  207.     'Resize the datagrid control to the UserControl object when we are in the Visual Basic Run Time mode.
  208.     grdDOCtl.Top = UserControl.ScaleTop
  209.     grdDOCtl.Left = UserControl.ScaleLeft
  210.     grdDOCtl.Height = UserControl.ScaleHeight
  211.     grdDOCtl.Width = UserControl.ScaleWidth
  212.     Exit Function
  213. InitDataObjClassErr:
  214. End Function
  215. Private Sub FillCombo(Ctrl As ComboBox, oRS As Recordset, nDescrField As String, bShowNone As Boolean)
  216. '=============================================================
  217. 'Name: FillCombo
  218. 'Author: Microsoft Data Object Wizard
  219. 'Date: 06/11/1998 18:39
  220. 'Description: Fills the Foreign Key as hidden in the combobox control
  221. 'Comment:
  222. '=============================================================
  223.     'Clear the floating combobox control
  224.     Ctrl.Clear
  225.     'If Foreign Key Identifier field is nullable then put '(None)' as the first record in listbox control
  226.     If bShowNone Then
  227.         Ctrl.AddItem "(None)"
  228.         Ctrl.ItemData(Ctrl.NewIndex) = -1
  229.     End If
  230.     'Move to the first record of the RecordSet class
  231.     oRS.MoveFirst
  232.     'Load the combobox control from the RecordSet class
  233.     While Not oRS.EOF
  234.         Ctrl.AddItem oRS(nDescrField)
  235.         Ctrl.ItemData(Ctrl.NewIndex) = oRS.AbsolutePosition
  236.         oRS.MoveNext
  237.     Wend
  238.     On Error Resume Next
  239.         Select Case grdDOCtl.Col
  240.             'Set the listbox control to the Foreign Key value.
  241.             Case CUSTOMERSCOMPANYNAME_COLUMN:
  242.                 If IsNull(oDataObjClass.customerid) Then
  243.                     Ctrl.ListIndex = 0
  244.                 Else
  245.                     Ctrl.ListIndex = GetSurKeyCustomers(oDataObjClass.customerid)
  246.                 End If
  247.         End Select
  248.     On Error GoTo 0
  249. End Sub
  250. Private Sub ShowFloatingControl(Ctrl As ComboBox, nColNumber As Integer, nRow As Integer)
  251. '=============================================================
  252. 'Name: ShowFloatingControl
  253. 'Author: Microsoft Data Object Wizard
  254. 'Date: 06/11/1998 18:39
  255. 'Description: Locates and unhides the Foreign Key listbox control.
  256. 'Comment:
  257. '=============================================================
  258.     Dim oCol As Column
  259.     'Set the listbox control to the clicked datagrid control column
  260.     Set oCol = grdDOCtl.Columns(nColNumber)
  261.     'Move and show the listbox control
  262.     With Ctrl
  263.         .Left = grdDOCtl.Left + oCol.Left
  264.         .Top = grdDOCtl.Top + grdDOCtl.rowtop(grdDOCtl.Row)
  265.         .Width = oCol.Width + Screen.TwipsPerPixelX
  266.         If nRow = -1 Then
  267.             .ListIndex = 0
  268.         Else
  269.             .ListIndex = nRow
  270.         End If
  271.         .ZOrder 0
  272.         'If the listbox control is outside of the datagrid control, don't show the datagrid control.
  273.         If oCol.Left + oCol.Width <= grdDOCtl.Left + grdDOCtl.Width Then
  274.             .Visible = True
  275.             .SetFocus
  276.         Else
  277.             grdDOCtl.Col = 0
  278.         End If
  279.     End With
  280. End Sub
  281. Private Sub grdDOCtl_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
  282. '=============================================================
  283. 'Name: grdDOCtlDataGrid_ButtonClick
  284. 'Author: Microsoft Data Object Wizard
  285. 'Date: 06/11/1998 18:39
  286. 'Description: Standard DataGrid control ButtonClick event code.
  287. 'Comment:
  288. '=============================================================
  289.     cmbEdit.Visible = False
  290.     'Exit the procudure if the GridEditable property is set to false
  291.     If mbFirstTime Or (Not mbShowCombo) Or (Not GridEditable) Then
  292.         Exit Sub
  293.     End If
  294.     'Save the datagrid controls current cell position
  295.     mlCurrentCol = grdDOCtl.Col
  296.     'Show the floating listbox control based on the datagrid controls column property
  297.     Select Case mlCurrentCol
  298.         'Fill the listbox control, set the control to the value of the Foreign Key and show it.
  299.         Case CUSTOMERSCOMPANYNAME_COLUMN:
  300.             FillCombo cmbEdit, oDataObjClass.rsCustomers, "CompanyName", True
  301.             If grdDOCtl.Row = -1 Then
  302.                 SendKeys cmbEdit.List(0)
  303.             Else
  304.                 If IsNull(oDataObjClass.customerid) Then
  305.                     ShowFloatingControl cmbEdit, CUSTOMERSCOMPANYNAME_COLUMN, -1
  306.                 Else
  307.                     ShowFloatingControl cmbEdit, CUSTOMERSCOMPANYNAME_COLUMN, GetSurKeyCustomers(grdDOCtl.Columns(CUSTOMERID_COLUMN).Text)
  308.                 End If
  309.             End If
  310.         Case Else
  311.             cmbEdit.Visible = False
  312.     End Select
  313. End Sub
  314. Private Sub grdDOCtl_Scroll(Cancel As Integer)
  315. '=============================================================
  316. 'Name: grdDOCtl_Scroll
  317. 'Author: Microsoft Data Object Wizard
  318. 'Date: 06/11/1998 18:39
  319. 'Description: Standard DataGrid control Scroll event.
  320. 'Comment:
  321. '=============================================================
  322.     'Hide the listbox control
  323.     cmbEdit.Visible = False
  324. End Sub
  325. Private Function GetSurKeyCustomers(customerid) As Integer
  326. '=============================================================
  327. 'Name: GetSurKeyCustomers
  328. 'Author: Microsoft Data Object Wizard
  329. 'Date: 06/11/1998 18:39
  330. 'Description: Moves the RecordSet class to the AbsolutePosition value of the Foreign Key parameters.
  331. 'Comment:
  332. '=============================================================
  333.     oDataObjClass.rsCustomers.MoveFirst
  334.     ' Loop through each record in the Foreign Key RecordSet class until we find the actual Foreign Key values
  335.     While Not oDataObjClass.rsCustomers.EOF
  336.         If oDataObjClass.rsCustomers("customerid").Value = (customerid) Then
  337.             'Return the Surrogate Key value.
  338.             GetSurKeyCustomers = oDataObjClass.rsCustomers.AbsolutePosition
  339.             Exit Function
  340.         End If
  341.         oDataObjClass.rsCustomers.MoveNext
  342.     Wend
  343.     'If the Surrogate Key (AbsolutePosition) value is not found, set the function to the first Recordset item
  344.     GetSurKeyCustomers = 1
  345. End Function
  346. Private Function UpdateFKCustomers(nSurrogateKey As Integer)
  347. '=============================================================
  348. 'Name: UpdateFKCustomers
  349. 'Author: Microsoft Data Object Wizard
  350. 'Date: 06/11/1998 18:39
  351. 'Description: Sets the Foreign Key properties based on the Surrogate Key value in the class.
  352. 'Comment:
  353. '=============================================================
  354.     If nSurrogateKey = -1 Then
  355.         'Set the actual Foreign Key value to null
  356.         oDataObjClass.customerid = Null
  357.     Else
  358.         oDataObjClass.rsCustomers.MoveFirst
  359.         'Move the Foreign Key RecordSet class to the Surrogate Key value(the AbsolutePosition property.)
  360.         While Not oDataObjClass.rsCustomers.EOF
  361.             If oDataObjClass.rsCustomers.AbsolutePosition = Val(nSurrogateKey) Then
  362.                 'Set the DataSource class property to the value of the Foreign Key RecordSet class field.
  363.                 oDataObjClass.customerid = oDataObjClass.rsCustomers("customerid")
  364.                 Exit Function
  365.             End If
  366.             oDataObjClass.rsCustomers.MoveNext
  367.         Wend
  368.     End If
  369. End Function
  370. Private Sub cmbEdit_Click()
  371. '=============================================================
  372. 'Name: cmbEdit_Click
  373. 'Author: Microsoft Data Object Wizard
  374. 'Date: 06/11/1998 18:39
  375. 'Description: Standard lstEdit control click event.
  376. 'Comment:
  377. '=============================================================
  378.     If cmbEdit.Visible Then
  379.         Select Case mlCurrentCol
  380.             Case CUSTOMERSCOMPANYNAME_COLUMN:
  381.                 'Run the UpdateFK method to update the DataSource class Foreign Key Property value(s).
  382.                 UpdateFKCustomers cmbEdit.ItemData(cmbEdit.ListIndex)
  383.         End Select
  384.         'Update the datagrid control's cell with the listbox control List value.
  385.         If cmbEdit.List(cmbEdit.ListIndex) = "(None)" Then
  386.             grdDOCtl.Text = "(None)"
  387.         Else
  388.             grdDOCtl.Text = cmbEdit.List(cmbEdit.ListIndex)
  389.         End If
  390.     End If
  391.     cmbEdit.Visible = False
  392. End Sub
  393. Private Sub oDataObjClass_ClassError(sProcedureName As String, oErr As ErrObject)
  394. '=============================================================
  395. 'Name: oDataObjClass
  396. 'Author: Microsoft Data Object Wizard
  397. 'Date: 06/11/1998 18:39
  398. 'Description: This subroutine performs the Sink action on the ClassError event.
  399. 'Comment:
  400. '=============================================================
  401.     Dim sStr As String
  402.     sStr = sProcedureName
  403.     If oErr.Description <> "" Then
  404.         sStr = sStr & oErr.Description
  405.     End If
  406.     mbClassError = True
  407.     MsgBox sStr
  408. End Sub
  409. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  410. '=============================================================
  411. 'Name: UserControl_ReadProperties
  412. 'Author: Microsoft Data Object Wizard
  413. 'Date: 06/11/1998 18:39
  414. 'Description: Standard UserControl object ReadProperties Event.
  415. 'Comment:
  416. '=============================================================
  417.     Dim bErrorFlag As Boolean
  418.     Dim sParamName As String
  419.     bErrorFlag = False
  420.     On Error GoTo errUserControl_ReadProperties
  421.     'Set ManualInitialize property to false to initialize the datagrid control automatically.
  422.     ManualInitialize = PropBag.ReadProperty("ManualInitialize")
  423.     'Set GridEditable property to true to allow editing of the datagrid control and activate Foreign Key listbox controls.
  424.     GridEditable = PropBag.ReadProperty("GridEditable")
  425.     If Not ManualInitialize Then
  426.         'Read the SaveMode property value.
  427.         sParamName = "SaveMode"
  428.         SaveMode = CLng(PropBag.ReadProperty("SaveMode"))
  429.         'If parameter values were read then initialize the DataSource class.
  430.         If Not bErrorFlag And Ambient.UserMode Then
  431.             InitDataObjClass
  432.         End If
  433.     End If
  434. Exit Sub
  435. errUserControl_ReadProperties:
  436.     bErrorFlag = True
  437.     Resume Next
  438. End Sub
  439. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  440. '=============================================================
  441. 'Name: UserControl_WriteProperties
  442. 'Author: Microsoft Data Object Wizard
  443. 'Date: 06/11/1998 18:39
  444. 'Description: Standard UserControl object WriteProperties event.
  445. 'Comment:
  446. '=============================================================
  447.     On Error Resume Next
  448.     'Set the ManualInitialize property to false to initialize the datagrid control automatically.
  449.     PropBag.WriteProperty "ManualInitialize", ManualInitialize
  450.     'Set the GridEditable property to true to allow editing the datagrid control and activate the Foreign Key listbox controls.
  451.     PropBag.WriteProperty "GridEditable", GridEditable
  452.     If Not ManualInitialize Then
  453.         'Write the SaveMove property value.
  454.         PropBag.WriteProperty "SaveMode", SaveMode
  455.     End If
  456.     On Error GoTo 0
  457. End Sub
  458. Private Sub UserControl_Resize()
  459. '=============================================================
  460. 'Name: UserControl_Resize
  461. 'Author: Microsoft Data Object Wizard
  462. 'Date: 06/11/1998 18:39
  463. 'Description: Standard UserControl object Resize event.
  464. 'Comment:
  465. '=============================================================
  466.     'Resize the datagrid control to the UserControl object when we are in Visual Basic Design Time mode.
  467.     grdDOCtl.Top = UserControl.ScaleTop
  468.     grdDOCtl.Left = UserControl.ScaleLeft
  469.     grdDOCtl.Height = UserControl.ScaleHeight
  470.     grdDOCtl.Width = UserControl.ScaleWidth
  471. End Sub
  472. Public Sub oDataObjClass_rsMoveComplete()
  473. '=============================================================
  474. 'Name: MoveComplete
  475. 'Author: Microsoft Data Object Wizard
  476. 'Date: 06/11/1998 18:39
  477. 'Description: UserControl object MoveComplete event.
  478. 'Comment:
  479. '=============================================================
  480.     RaiseEvent MoveComplete(oDataObjClass)
  481. End Sub
  482. Private Sub grdDOCtl_ColResize(ByVal ColIndex As Integer, Cancel As Integer)
  483. '=============================================================
  484. 'Name: grdDOCtl_ColResize
  485. 'Author: Microsoft Data Object Wizard
  486. 'Date: 06/11/1998 18:39
  487. 'Description: Standard DataGrid control ColResize event.
  488. 'Comment:
  489. '=============================================================
  490.     If cmbEdit.Visible Then
  491.         If grdDOCtl.Columns(mlCurrentCol).Left + grdDOCtl.Columns(mlCurrentCol).Width <= grdDOCtl.Left + grdDOCtl.Width Then
  492.             'If the listbox control does not extend past the datagrid control, then resize the listbox control to the column width of the datagrid control.
  493.             cmbEdit.Left = grdDOCtl.Left + grdDOCtl.Columns(mlCurrentCol).Left
  494.             cmbEdit.Width = grdDOCtl.Columns(mlCurrentCol).Width
  495.         Else
  496.             'If the listbox control extends past the datagrid control, then do not show the listbox control.
  497.             cmbEdit.Visible = False
  498.         End If
  499.     End If
  500. End Sub
  501. Private Sub grdDOCtl_KeyPress(KeyAscii As Integer)
  502. '=============================================================
  503. 'Name: grdDOCtl_KeyPress
  504. 'Author: Microsoft Data Object Wizard
  505. 'Date: 06/11/1998 18:39
  506. 'Description: Standard DataGrid control KeyPress event.
  507. 'Comment:
  508. '=============================================================
  509.     Select Case grdDOCtl.Col
  510.         Case Is = CUSTOMERSCOMPANYNAME_COLUMN
  511.             KeyAscii = 0
  512.     End Select
  513. End Sub
  514.