Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there an equivalent of "AfterRowColChange" in Listbox control? 1

Rajesh Karunakaran

Programmer
Joined
Sep 29, 2016
Messages
561
Location
MU
Hi Friends,

I have a list box whose RowSource is a cursor.
Is there an event in Listbox control equivalent to the "AfterRowColChange" event of a Grid control ?

My requirement is to show the value from the current record in a textbox below the listbox as the user go un and down in the listbox.

Thanks in advance
 
Hi Joe,

Yes, it's working!
Opps! my mistake. I knew, I saw it also but didn't try it before posting here 🤦‍♀️

Thanks
 
Hi,

To illustrate Joe's answer, please have a look a the code below

Code:
PUBLIC go_Form

go_Form=CREATEOBJECT("clsForm")
go_Form.Visible = .T.
go_Form.Show()

READ Events


CLOSE ALL
CLEAR ALL

************

DEFINE CLASS clsForm as Form

    AutoCenter = .T.
    Width = 420
    MinWidth = 420
    MaxWidth = 420
    Height = 360
    MinHeight = 360
    MaxHeight = 360
    ShowTips = .T.
   
   
    ADD OBJECT lblLabel as Label WITH Top = 6, Left = 6, Autosize = .T., ;
                Caption = "Name", Anchor = 3

    ADD OBJECT txtName as TextBox WITH Top = 30, Left = 258, Width = 90, Height = 24, ReadOnly = .T., Anchor = 3, ;
        DisabledBackColor = RGB(250, 250, 250), ToolTipText = "Name"

    ADD OBJECT txtNumber as TextBox WITH Top = 60, Left = 258, Width = 90, Height = 24, ReadOnly = .T., Anchor = 3, ;
        Alignment = 1, DisabledBackColor = RGB(250, 250, 250), ToolTipText = "ID"                                  
   
    ADD OBJECT txtGender as TextBox WITH Top = 90, Left = 258, Width = 90, Height = 24, ReadOnly = .T., Anchor = 3, ;
        DisabledBackColor = RGB(250, 250, 250), ToolTipText = "Gender"

    ADD OBJECT txtHeight as TextBox WITH Top = 120, Left = 258, Width = 90, Height = 24, ReadOnly = .T., Anchor = 3, ;
        DisabledBackColor = RGB(250, 250, 250), Alignment = 1, ToolTipText = "Height"

    ADD OBJECT cboBox as ComboBox WITH Top = 30, Left = 6, Width = 240, Height = 24, ;
            RowSourceType = 2, RowSource = "csrEmployees", Style = 2, Sorted = .T., ;
            Anchor = 3, ToolTipText = "Type name or click down arrow"
           
        PROCEDURE cboBox.Init()
            This.Value = csrEmployees.cName
           
            WITH ThisForm
                .txtName.Value = csrEmployees.cName
                .txtNumber.Value = csrEmployees.iNumber
                .txtGender.Value = csrEmployees.cGender
                .txtHeight.Value = csrEmployees.nHeight
            ENDWITH
           
            This.SetFocus()                

        ENDPROC
       
*!*    START of procedure that feeds the TextBoxes with their values

        PROCEDURE cboBox.Click()
       
            WITH ThisForm
                .txtName.Value = csrEmployees.cName
                .txtNumber.Value = csrEmployees.iNumber
                .txtGender.Value = csrEmployees.cGender
                .txtHeight.Value = csrEmployees.nHeight
            ENDWITH
       
        ENDPROC

*!*    END of the feeding procedure
   
        PROCEDURE cboBox.InterActiveChange()
       
            This.Click()
           
        ENDPROC

    PROCEDURE Load()
        CREATE CURSOR csrNames (cName c(8),iNumber I, cGender c(1), nHeight N(5,2))
       
        INSERT INTO csrNames VALUES ('Karl', 123, 'M', 1.75)
        INSERT INTO csrNames VALUES ('Robert', 124, 'M', 1.80)
        INSERT INTO csrNames VALUES ('Luisa', 125, 'F', 1.70)
        INSERT INTO csrNames VALUES ('Megan', 126, 'F', 1.68)
        INSERT INTO csrNames VALUES ('Georges', 127, 'M', 1.82)
        INSERT INTO csrNames VALUES ('Kim', 128, 'F', 1.65)
        INSERT INTO csrNames VALUES ('Paul', 129, 'M', 1.85)
        INSERT INTO csrNames VALUES ('Corinne', 130, 'F', 1.54)
        INSERT INTO csrNames VALUES ('Elisa', 131, 'F', 1.68)
        INSERT INTO csrNames VALUES ('John', 132, 'M', 1.72)
        INSERT INTO csrNames VALUES ('Frank', 133, 'M', 1.90)
       
        SELECT * FROM csrNames ORDER BY 1 INTO CURSOR csrEmployees      
    ENDPROC

    PROCEDURE Destroy()
        USE
        ThisForm.Release
        CLEAR Events
   
    ENDPROC
ENDDEFINE

************

hth

MarK
 
The grid has an active row, always one is a current row with the record pointer on it. The listbox has selected items, there can also be none selected or you can have multiselect, those are totally different concepts.

Well, good that InteractiveChange works for your case.
 

Part and Inventory Search

Sponsor

Back
Top