Aaron,
Thanks for your reply. Using the CreateEditOption seems to of done the trick bar one small problem. When I click into the Cell. Even if the text matchs what is in the constrait, it blanks the entry. If I select it from the drop down it is fine.
As I don't know how to post a sample I will just copy all my current code below. You will need to add a Report Control to a form and call it grdSample.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Option Explicit Private Sub Form_Load() On Error GoTo ERR_HANDLER Call SetupGrid Call AddRecordToGrid(1) Call AddRecordToGrid(2) Call AddRecordToGrid(3) Call AddRecordToGrid(4) Exit Sub ERR_HANDLER: MsgBox "Error in Form1.frm::Sub Form_Load: Error " & Err.Number & " - " & Err.Description End Sub Private Sub AddRecordToGrid(ByVal RecordID As Integer) On Error GoTo ERR_HANDLER Dim objRecord As ReportRecord Dim objRecordItem As ReportRecordItem Set objRecord = grdSample.Records.Add() Set objRecordItem = objRecord.AddItem(RecordID) Set objRecordItem = objRecord.AddItem(Trim("Line " & CStr(RecordID))) Set objRecordItem = objRecord.AddItem("Some random notes") Set objRecordItem = Nothing Set objRecord = Nothing grdSample.Populate grdSample.Redraw Exit Sub ERR_HANDLER: MsgBox "Error in Form1.frm::Sub AddRecordToGrid: Error " & Err.Number & " - " & Err.Description End Sub Private Sub SetupGrid() On Error GoTo ERR_HANDLER With grdSample 'Set Grid Properties .AllowEdit = True .FocusSubItems = True 'Clear grid before populating .Records.DeleteAll .Columns.DeleteAll 'Add Columns .Columns.Add 0, "ID", 20, False .Columns.Add 1, "User", 80, False .Columns.Add 2, "Notes", 200, False 'Set which columns can be edited .Columns(0).Editable = False .Columns(1).Editable = True .Columns(2).Editable = True 'Add combo to required columns .Columns(1).EditOptions.AddComboButton End With Exit Sub ERR_HANDLER: MsgBox "Error in Form1.frm::Sub SetupGrid: Error " & Err.Number & " - " & Err.Description End Sub Private Sub grdSample_FocusChanging(ByVal NewRow As XtremeReportControl.IReportRow, ByVal NewColumn As XtremeReportControl.IReportColumn, ByVal NewItem As XtremeReportControl.IReportRecordItem, Cancel As Boolean) On Error GoTo ERR_HANDLER If NewColumn.Index = 1 Then NewItem.CreateEditOptions NewItem.EditOptions.ConstraintEdit = True NewItem.EditOptions.Constraints.DeleteAll NewItem.EditOptions.RemoveButtons NewItem.EditOptions.AddComboButton NewItem.EditOptions.Constraints.Add "Line 1", 0 NewItem.EditOptions.Constraints.Add "Line 2", 1 NewItem.EditOptions.Constraints.Add "Line 3", 2 grdSample.Redraw End If Exit Sub ERR_HANDLER: MsgBox "Error in Form1.frm::Sub grdSample_FocusChanging: Error " & Err.Number & " - " & Err.Description End Sub
|