Good day! I have a code that import my table on a listbox and able to add on it.
i was stock on some codes when i double click a selected value on my listbox to open another dialogbox to edit (the selected value) it as well as on my table.
Heres my code...
Include "Mapbasic.def" Declare Sub Main Declare Sub AddItemDialog Declare Sub AlterMainDialog declare sub editlistDialog declare sub Nodelist(byval sId as string) dim listboxValues() as string declare sub listbox_edit '--------------------------------------------------------------------------- Sub Main Dialog Title "Main Dialog" Width 150 Height 80 calling editlistDialog Control ListBox Position 13, 7 Width 100 Height 50 ID 1 Title from variable listboxValues calling listbox_edit Control Button Title "Add Item" ID 2 Calling AddItemDialog Control OkButton Control CancelButton End Sub '--------------------------------------------------------------------------- Sub AddItemDialog Dim strAddItem as String Dialog Title "Add Item Dialog" Control EditText Width 100 Into strAddItem Control OkButton Title "Add" Control CancelButton If CommandInfo(CMD_INFO_DLG_OK) Then Dim i as Integer i = Ubound(listboxValues) Redim listboxValues( i + 1) i = Ubound(listboxValues) listboxValues(i) = strAddItem insert into subn(lname) values(strAddItem) Call AlterMainDialog End If End Sub '--------------------------------------------------------------------------- Sub AlterMainDialog Alter Control 1 Title from variable listboxValues End Sub '--------------------------------------------------------------------------- sub editlistDialog call Nodelist("5350") alter control 1 title from variable listboxValues End Sub '--------------------------------------------------------------------------- sub Nodelist(byval sId as string) dim i as integer dim nRows as integer select * from subn where site=sId into lstValues noselect nRows=tableinfo("lstValues",tab_info_nrows) redim listboxValues(nrows) for i = 1 to tableinfo("lstValues",tab_info_nrows) fetch rec i from lstValues listboxValues(i)=lstValues.lname Next End Sub '--------------------------------------------------------------------------- Sub listbox_edit Dim i as string If CommandInfo(CMD_INFO_DLG_DBL) = TRUE Then ' ...then the user DOUBLE-clicked. ' see which list item the user clicked on. i = ReadControlValue(1) print i 'Should try to look the table and edit list End If End Sub br,
Ivan
أكثر...
i was stock on some codes when i double click a selected value on my listbox to open another dialogbox to edit (the selected value) it as well as on my table.
Heres my code...
Include "Mapbasic.def" Declare Sub Main Declare Sub AddItemDialog Declare Sub AlterMainDialog declare sub editlistDialog declare sub Nodelist(byval sId as string) dim listboxValues() as string declare sub listbox_edit '--------------------------------------------------------------------------- Sub Main Dialog Title "Main Dialog" Width 150 Height 80 calling editlistDialog Control ListBox Position 13, 7 Width 100 Height 50 ID 1 Title from variable listboxValues calling listbox_edit Control Button Title "Add Item" ID 2 Calling AddItemDialog Control OkButton Control CancelButton End Sub '--------------------------------------------------------------------------- Sub AddItemDialog Dim strAddItem as String Dialog Title "Add Item Dialog" Control EditText Width 100 Into strAddItem Control OkButton Title "Add" Control CancelButton If CommandInfo(CMD_INFO_DLG_OK) Then Dim i as Integer i = Ubound(listboxValues) Redim listboxValues( i + 1) i = Ubound(listboxValues) listboxValues(i) = strAddItem insert into subn(lname) values(strAddItem) Call AlterMainDialog End If End Sub '--------------------------------------------------------------------------- Sub AlterMainDialog Alter Control 1 Title from variable listboxValues End Sub '--------------------------------------------------------------------------- sub editlistDialog call Nodelist("5350") alter control 1 title from variable listboxValues End Sub '--------------------------------------------------------------------------- sub Nodelist(byval sId as string) dim i as integer dim nRows as integer select * from subn where site=sId into lstValues noselect nRows=tableinfo("lstValues",tab_info_nrows) redim listboxValues(nrows) for i = 1 to tableinfo("lstValues",tab_info_nrows) fetch rec i from lstValues listboxValues(i)=lstValues.lname Next End Sub '--------------------------------------------------------------------------- Sub listbox_edit Dim i as string If CommandInfo(CMD_INFO_DLG_DBL) = TRUE Then ' ...then the user DOUBLE-clicked. ' see which list item the user clicked on. i = ReadControlValue(1) print i 'Should try to look the table and edit list End If End Sub br,
Ivan
أكثر...