I want a Xdialog Box list view control to allow the user to highlight multiple rows by left click and dragging just as you can on any browse or form. The list view does not have the small gap at the beginning for highlighting rows. This gap is present in most of the other basic data browses on Alpha. Is there a way to implement this in the xbasic code?
xbasic code :
xbasic code :
Code:
'Date Created: 02-Jul-2014 04:17:41 PM 'Last Updated: 02-Jul-2014 04:17:41 PM 'Created By : Admin 'Updated By : Admin 'Create an XDialog dialog box to prompt for parameters. DIM SHARED g as C DIM SHARED varC_result as C DIM vlv_FuncCode AS C = <<%CodeFunctions% FUNCTION DoSort AS V (byref CurrentSortField AS C , byref CurrentSortDirection AS C, NewSortField AS C, Filter AS C, pLV AS P, rs AS P ) DIM cResult AS C DIM SortDirection AS C DIM SortField AS C IF NewSortField = CurrentSortField ' clicked on same field, reverse sort IF CurrentSortDirection = "D" CurrentSortDirection = "A" ELSE CurrentSortDirection = "D" END IF ELSE CurrentSortField = NewSortField CurrentSortDirection = "A" END IF SortDirection = CurrentSortDirection SortField = CurrentSortField IF SortDirection = "D" SortField = "invert(" + SortField + ")" END IF ' actual sorting code goes here pLV.RowView.Close() pLV.RowView = rs.OpenView(1, SortField, Filter) DoSort = cResult END FUNCTION %CodeFunctions% DIM vlv_Funcs AS P = compile_template(vlv_FuncCode) DIM SHARED vlv AS C DIM vlv_CurrentSortField AS C = "" DIM vlv_CurrentSortDirection AS C = "A" DIM vlv_Filter AS C DIM vlv_pTableDef AS P DIM vlv_pTableDef.ReturnValueExpression AS C = "Customer_id" DIM vlv_pTableDef.FieldList AS C = <<%txt% Customer_id Firstname Lastname Company Bill_address_1 Bill_city Bill_state_region %txt% DIM vlv_pTableDef.TitleRow AS C = "{AUTOSIZE}Customer_id|{AUTOSIZE}Firstname|{AUTOSIZE}Lastname|{AUTOSIZE}Company|{AUTOSIZE}Bill_address_1|{AUTOSIZE}Bill_city|{AUTOSIZE}Bill_state_region" DIM vlv_pTableDef.TableName AS C = "customer" DIM vlv_pTableDef.Filter AS C = "(recno() > 0)" ' recno() > 0 is required in order to avoid showing deleted variables DIM vlv_pTableDef.Order AS C = "" DIM vlv_pTableDef.pAdvFormatting AS P DIM vlv_pTableDef.pAdvFormatting.alternating_bands AS L = .t. DIM vlv_pTableDef.pAdvFormatting.group_size AS N = 1 DIM vlv_pTableDef.pAdvFormatting.odd_row_color AS C = "White" DIM vlv_pTableDef.pAdvFormatting.even_row_color AS C = "Blue White" DIM vlv_pTableDef.pAdvFormatting.odd_selected_color AS C = "Dark Blue" DIM vlv_pTableDef.pAdvFormatting.even_selected_color AS C = "Dark Blue" DIM vlv_pTableDef.pAdvFormatting.font AS C = "Arial,8" DIM vlv_pTableDef.pAdvFormatting.font_color_unselected AS C = "Black" DIM vlv_pTableDef.pAdvFormatting.font_color_selected AS C = "White" DIM vlv_pTableDef.pAdvFormatting.number_rows AS L = .f. DIM vlv_pTableDef.pAdvFormatting.tab_stops AS C = "" vlv_pLV.titlerow = vlv_pTableDef.titlerow vlv_pLV.titleevents = "vlv_Sort_Customer_id|vlv_Sort_Firstname|vlv_Sort_Lastname|vlv_Sort_Company|vlv_Sort_Bill_address_1|vlv_Sort_Bill_city|vlv_Sort_Bill_state_region" vlv_pLV.style = "report,showselalways,gridlines,fullrowselect" vlv_pLV.dragbehaviour = "" vlv_pLV.dropbehaviour = "" DIM vlv_t AS P DIM vlv_rr AS Alpha5::RowRelation DIM vlv_rs AS P IF .NOT. file.exists(table.filename_get(vlv_pTableDef.TableName)) END END IF vlv_t = table.open(vlv_pTableDef.TableName, FILE_RO_SHARED) vlv_t.persist() vlv_rs = vlv_rr.TableToRowSource(vlv_t) vlv_Filter = vlv_pTableDef.Filter vlv_pLV.rowview = vlv_rs.OpenView(1,vlv_pTableDef.Order,vlv_Filter) vlv_pLV.RowSeparator = crlf() vlv_pLV.ColumnSeparator = "|" vlv_pLV.Key = vlv_pTableDef.ReturnValueExpression vlv_pLV.Columns = a5_owner_draw_list_fmt(vlv_pTableDef.FieldList, vlv_pTableDef.pAdvFormatting, "listviewvirtual") vlv_pLV.events = <<%code% function OnRightClick as c(lv as p,listView as p,args as p) WITH lv listView.Selection = listView.GetRowValue(args.GetClickRow()) OnSelectionChanged(lv, listView ) 'to call a function outside the events code, you must use the ui_dlg_eval() function 'menu = ui_dlg_eval(dlg_title,"a5wcb_PublishRclick(selectedFilename)") ' ui_msg_box("OnRightClick",listview.selection) END WITH end function function OnDoubleClick as c(lv as p,listView as p,args as p) WITH lv vlv = listView.GetRowValue(args.GetClickRow()) ' ui_msg_box("OnDoubleClick",vlv) END WITH end function FUNCTION OnSelectionChanged AS V (lv AS P, listView as p ) WITH lv vlv = listView.Selection ' ui_msg_box("OnSelectionChanged",vlv) END WITH END FUNCTION FUNCTION OnKeyDown as v(vars as p,listView as p,args as p) DIM key AS C Dim KeyName as c key = args.GetKeyName() KeyName = key IF key = "{Delete}" .OR. key = "{Num Del}" KeyName = "{Delete}" ELSE IF args.keycode = 13 ' enter KeyName = "{Enter}" ELSE IF args.keycode = 8 ' backspace KeyName = "{Backspace}" END IF 'ui_msg_box("OnKeyDown", KeyName) END FUNCTION %code% DELETE a_g DIM a_g[4] as c dim temp_list as c temp_list = <<%list% h a d s %list% a_g.initialize(temp_list) heading_string = "Data is dynamically bound to the table so the table size does not impact the performance of the list. You can use this type of listview with very large tables." ok_button_label = "&OK" cancel_button_label = "&Cancel" varC_result = ui_dlg_box("Virtual Listview",<<%dlg% {region} {text=215,1:heading_string}; {endregion}; {rightclick=menu1} {region} | {listviewvirtual=200,20vlv^=vlv_pLV}; {watch=vlv!foo}; Type prompt here:| [%v%.37g^=a_g]; {endregion}; {line=1,0}; {rightclick=menu2} {region} <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL> {endregion}; %dlg%,<<%code% IF left(a_dlg_button, len("vlv_Sort_")) = "vlv_Sort_" DIM NewSortField AS C NewSortField = substr(a_dlg_button, len("vlv_Sort_")+1) vlv_Funcs.DoSort(vlv_CurrentSortField, vlv_CurrentSortDirection, NewSortField, vlv_Filter, vlv_pLV, vlv_rs) a_dlg_button = "" END IF IF a_Dlg_button = "vlv_refresh" a_dlg_button = "" vlv_pLV.RowView.Close() vlv_pLV.RowView = vlv_rs.OpenView(1, vlv_CurrentSortField, vlv_Filter) END IF IF a_dlg_button = "foo" a_dlg_button = "" ' do nothing END IF if a_dlg_button = "menu1" then ui_msg_box("Menu1","User right-clicked") a_dlg_button = "" end if if a_dlg_button = "menu2" then menu = <<%a% Cut Copy Paste %a% result = ui_popup_menu(menu) ui_msg_box("Menu2","User selected: " + result) a_dlg_button = "" end if %code%) vlv_t.close()
Comment