Building a single select List Box

Started by Kerry, December 09, 2014, 02:53:36 PM

Previous topic - Next topic

Kerry


Has anyone built a listbox ( similar to upper piccy shown )

I tried using a listView and can't get reduced height rows to dosplay ; and can't remove the first empty column.

I want something that is called like this

Code (autolisp) Select
(call_listbox (strcat "Re-path : " xrefName)
             "Select a File name"
             (list candidateFile candidateFile candidateFile)
)


My feeble attempt is fugly.



Perfection is not optional.
My other home is TheSwamp

Kerry

#1
Perhaps I should read this http://www.opendcl.com/forum/index.php?topic=2213.0;topicseen

.. or one of the 100 odd posts that refer to ListView

I'll be back tomorrow.
Perfection is not optional.
My other home is TheSwamp

owenwengerd

Is there some reason why you can't use the List Box control?

Kerry

Quote from: owenwengerd on December 09, 2014, 03:03:29 PM
Is there some reason why you can't use the List Box control?
Probably 'cause I couldn't see the trees for the forest ...
It's been a while since I built new ODCL dialogs :-)
Perfection is not optional.
My other home is TheSwamp

Kerry

DUH !!

I've used the ListBox umpteen times before.

I'm Blind as well as silly.

Thanks Owen
Perfection is not optional.
My other home is TheSwamp

owenwengerd

I'm glad you're coming out of retirement. Metaphorically, that is.

Kerry

#6
after my nap ...
Thanks for the nudge in the correct direction Owen.

Code (autolisp) Select

;; (vlisp-compile 'st (findfile "N:\\kdub-listboxSource.lsp") "N:\\kdub-listbox.fas")

(defun c:doit (/ ui-captionString ui-promptString ui-listContent UIReturn)
  ;; Proof of concept code for listbox Single Selection
  (setq ui-captionString nil
        ui-promptString nil
        ui-listContent
         (list
           "N:\\Project_XYZ\\10_Drawings\\02_Xref\\03_SubFolder\\XR_AR_N+00.dwg"
           "Another Option ... pick me pick me"
           "Yet another option"
         )
        ui-SelectedList nil
  )

  ;;
  (if (not (member "kdub-ListBox" (dcl_getprojects)))
    (dcl_project_load "kdub-ListBox")
  )
  (if dcl_hideerrormsgbox
    (setq UIReturn (dcl-form-show kdub-ListBox/Form))
    (alert "The OpenDCL arx module did not load!")
  )
  (cond
    ((and (= UIReturn 100)
          ui-SelectedList
     )
     ;; display for multi Selection Style ( for later )
     (dcl-messagebox (apply
                       'strcat
                       (mapcar
                         '(lambda (x)
                            (strcat "\n" x)
                          )
                         ui-SelectedList
                       )
                     )
                     "Result of ui-SelectedList"
     )
    )
    (t
     ;;for clean up later
     (princ)
    )
  )
  (setq ui-SelectedList nil)
  (princ)
)
;;----------------------------------------


(defun c:kdub-ListBox/Form#OnInitialize (/)
  (if ui-captionString
    (dcl-control-setcaption
      kdub-ListBox/Form/xrefName
      ui-captionString
    )
  )
  (if ui-promptString
    (dcl-control-setcaption kdub-ListBox/Form/prompt ui-promptstring)
  )
  (dcl-listbox-clear kdub-ListBox/Form/ListBox)
  (dcl-listbox-addlist
    kdub-ListBox/Form/ListBox
    ui-listContent
  )
)
;;----------------------------------------
(defun c:kdub-ListBox/Form/OK#OnClicked (/)
  (setq ui-SelectedList (dcl-listbox-getselecteditems
                          kdub-ListBox/Form/ListBox
                        )
  )
  (dcl-form-close kdub-ListBox/Form 100)
)
;;----------------------------------------
(defun c:kdub-ListBox/Form/Cancel#OnClicked (/)
  ;; do nothing here at the moment
  (dcl-form-close kdub-ListBox/Form 99)
  (princ)
)

;;;--------------------------------------------------------------------------------
(if (not (vl-bb-ref 'kdubListBoxUI))
  (vl-bb-set
    'kdubListBoxUI
    (dcl_project_import
      '("Refer the attached file for dialog code .. "
         "The message exceeds the maximum allowed length (20000 characters)"
       )
    )
  )
)
(princ
  "\n kdub-ListBox Build 2014.12.10-v0.1\nTo run App enter: DOIT at the command line\n"
)

(princ)



BTW:
It would be nice if the dcl-MessageBox was re-sizable.

Added : and even nicer if it could AutoSize for long display strings     ;) ;D
Perfection is not optional.
My other home is TheSwamp