Print Page | Close Window

SOLVED: EditOptions.Constraints

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=11403
Printed Date: 05 October 2024 at 2:23am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: SOLVED: EditOptions.Constraints
Posted By: eswohnai
Subject: SOLVED: EditOptions.Constraints
Date Posted: 11 July 2008 at 11:38am
I have a Report Control where I need to fill a Combo with custom values. 
 
If there is already one instance of a value on the Grid,  when I go to a different row, and go into the Combo that item needs removing.
 
The way I was going to do it to call .EditOptions.Constraints.DeleteAll before repopulating the Constraints but this is removing all entries for my Column.
 
Does any one have any suggestions for getting around this?
 



Replies:
Posted By: Aaron
Date Posted: 11 July 2008 at 3:16pm
Hi,
 
Do you use CreateEditOption for a single cell? And use the InplaceButtonDown event to delete all constraints?
 
 
Can you upload a sample project?
 
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: eswohnai
Date Posted: 14 July 2008 at 7:16am

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



Posted By: eswohnai
Date Posted: 14 July 2008 at 9:01am
I've now managed to work around this.
 
The work round was to the add the following routine.
 
Thanks for your help
 
>>>>>>>>>>>>>>>>>>>>>
Private Sub grdSample_ValueChanged(ByVal Row As XtremeReportControl.IReportRow, ByVal Column As XtremeReportControl.IReportColumn, ByVal Item As XtremeReportControl.IReportRecordItem)
   
    On Error GoTo ERR_HANDLER
   
    If Column.Index = 1 Then
       
        Item.Caption = Item.EditOptions.Constraints(Item.Value).Caption
       
    End If
   
    Exit Sub
   
ERR_HANDLER:
   
    MsgBox "Error in Form1.frm::Sub grdSample_ValueChanged: Error " & Err.Number & " - " & Err.Description
   
End Sub



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net