Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use Grid.RowAddSetMS
#1
Photo 
I am trying to add a new row to the grid via a button.  the functionality works BUT the text strings sits in the first cell and doesnt get allocated to each cell in the row. i even tried with g.FromCSV(_s, ",") and it fails. whats the proper syntax? whats the diff between RowAddSetSA (whats SA & MS mean) 

thanks   *Screenshot below

case 4
Code:
Copy      Help
    _s=
     new,new1,new2,new3,new4,Yes,new5
    out _s
    g.RowAddSetMS(0 _s 7 0)


entire code
Code:
Copy      Help
\Dialog_Editor


 Shows how to use DlgGrid variable and grid notifications.
 All this is not necessary in most cases. Instead you can define style and columns in dialog editor. Then you can add/get data using the dialog variable.

str dd=
 BEGIN DIALOG
 0 "" 0x90C80AC8 0x0 0 0 352 135 "Dialog"
 3 QM_Grid 0x54030000 0x200 0 0 352 114 ""
 4 Button 0x54032000 0x0 4 116 48 14 "Add Row"
 1 Button 0x54030001 0x4 120 116 48 14 "OK"
 2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
 END DIALOG
 DIALOG EDITOR: "" 0x2040A00 "" "" "" ""

if(!ShowDialog(dd &sub.DlgProc)) ret


#sub DlgProc
function# hDlg message wParam lParam

DlgGrid g.Init(hDlg 3)
sel message
    case WM_INITDIALOG
    
     add columns
    g.ColumnsAdd("col0,10%[]edit,10%[]edit+button,20%,16[]edit multiline,20%,8[]combo,15%,1[]check,10%,2[]read-only,15%,7" 1)
     optionally add data using CSV string
    _s=
     a1,b1,c1,d1,e1,Yes,g1
     a2,b2,"""c2""","line1
     line2","1,2",,"  g2  "
    out _s
    g.FromCsv(_s ",")
     or you can add data from an ICsv variable
    
    case WM_DESTROY
    case WM_COMMAND goto messages2
    
ret
 messages2
sel wParam
    case IDOK
#endregion

    case 4
    _s=
     new,new1,new2,new3,new4,Yes,new5
    out _s
    g.RowAddSetMS(0 _s 7 0)
ret 1

[Image: FlQxbcZ.png]
#2
Function Function11
Code:
Copy      Help
,case 4
,_s="new[]new1[]new2[]new3[]new4[]Yes[]new5"
,ARRAY(str) newlist
,newlist=_s
,g.RowAddSetSA(0 &newlist[0] 7)
,

My guess SA= str array and MS= multi string
#3
thanks redbull, works perfectly,

quick question... one of my cells is a combo-box (can have multi items listed) how would i populate these combo boxes with a string or array of values?  do you happen to know the syntax? or point me to the help section taht covers this? (if no i can always create a new post)

thanks again
#4
Function sample_Grid
Code:
Copy      Help
\Dialog_Editor

;Shows how to use DlgGrid variable and grid notifications.
;All this is not necessary in most cases. Instead you can define style and columns in dialog editor. Then you can add/get data using the dialog variable.

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 352 135 "Dialog"
;3 QM_Grid 0x54030000 0x200 0 0 352 114 ""
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030202 "" "" ""

if(!ShowDialog(dd &sub.DlgProc)) ret


#sub DlgProc
function# hDlg message wParam lParam

DlgGrid g.Init(hDlg 3)
sel message
,case WM_INITDIALOG
,
,;optionally set grid style. Default is fully editable.
,;g.GridStyleSet(GRID.QG_NOEDIT|GRID.QG_NOAUTOADD) ;;read-only grid
,;g.GridStyleSet(GRID.QG_NOEDITFIRSTCOLUMN|GRID.QG_NOAUTOADD|GRID.QG_SETROWTYPE) ;;property grid
,
,;add columns
,g.ColumnsAdd("col0,10%[]edit,10%[]edit+button,20%,16[]edit multiline,20%,8[]combo,15%,1[]check,10%,2[]read-only,15%,7" 1)
,
,;optionally add data using CSV string
,_s=
,;a1,b1,c1,d1,e1,Yes,g1
,;a2,b2,"""c2""","line1
,;line2","1,2",,"  g2  "
,g.FromCsv(_s ",")
,;or you can add data from an ICsv variable
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,;get data
,g.ToCsv(_s ",")
,ShowText "" _s
,
,;or you can get it into an ICsv variable
,ICsv c._create
,g.ToICsv(c) ;;same as c.FromQmGrid(g)
,int i j
,for i 0 c.RowCount
,,out "--- row %i ---" i+1
,,for j 0 c.ColumnCount
,,,out c.Cell(i j)
,
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.idFrom
,case 3
,GRID.QM_NMLVDATA* cd=+nh
,NMLVDISPINFO* di=+nh
,NMLISTVIEW* nlv=+nh
,NMITEMACTIVATE* na=+nh
,sel nh.code
,,
,,;These notifications are from QM_Grid.
,,;All text coming from QM_Grid is in QM format (UTF-8 or ANSI, depending on QM Unicode mode).
,,
,,case LVN_BEGINLABELEDIT ;;when begins cell edit mode
,,out "begin edit: item=%i subitem=%i text=%s" di.item.iItem di.item.iSubItem di.item.pszText
,,if di.item.iSubItem=2
,,,g.SetButtonProp(1 "Browse...")
,,
,,case LVN_ENDLABELEDIT ;;when ends cell edit mode
,,out "end edit: item=%i subitem=%i text=%s" di.item.iItem di.item.iSubItem di.item.pszText
,,
,,case GRID.LVN_QG_BUTTONCLICK ;;when user clicks button
,,out "button: item=%i subitem=%i text=%s" cd.item cd.subitem cd.txt
,,if cd.subitem=2
,,,if(OpenSaveDialog(0 _s)) _s.setwintext(cd.hctrl)
,,
,,case GRID.LVN_QG_COMBOFILL ;;when user clicks combo box arrow
,,out "combo fill: item=%i subitem=%i" cd.item cd.subitem
,,if cd.subitem=4
,,,TO_CBFill cd.hcb "one[]two[]show inp"
,,
,,case GRID.LVN_QG_COMBOITEMCLICK ;;when user clicks combo box item
,,out "combo click: item=%i subitem=%i cbitem=%i text=%s" cd.item cd.subitem cd.cbindex cd.txt
,,if cd.cbindex=2
,,,if inp(_s)
,,,,_s.setwintext(cd.hctrl)
,,,,ret DT_Ret(hDlg 1)
,,
,,case GRID.LVN_QG_CHANGE ;;when user changes grid content
,,if(cd.hctrl) out "text changed: item=%i, subitem=%i, text=%s, newtext=%s" cd.item cd.subitem cd.txt _s.getwintext(cd.hctrl)
,,else out "grid changed" ;;eg row deleted
,,
,,;These notifications are from SysListView32.
,,;All text coming from SysListView32 is in UTF-16 format.
,,
,,case LVN_INSERTITEM ;;when user inserts new row
,,out "inserted %i" nlv.iItem
,,
,,case LVN_ITEMCHANGED ;;when row state changes. If user selects multiple items with Shift, this is sent once.
,,if(nlv.iItem<0 or nlv.uNewState&LVIS_SELECTED=0) ret
,,out "selected %i" nlv.iItem ;;selected listview item index
,,
,,case [NM_CLICK,NM_DBLCLK,NM_RCLICK] ;;when user clicks a row or empty space, and it does not begin cell edit mode
,,out "row click: %i %i" na.iItem na.iSubItem
,,
,,case LVN_ITEMACTIVATE ;;when user clicks or double clicks a row (depends on list view extended style), and it does not begin cell edit mode
,,out "item activated: %i %i" na.iItem na.iSubItem
,,
,,case LVN_COLUMNCLICK ;;click header
,,g.Sort(4|0x10000 nlv.iSubItem)


press F1 on a function there is plenty of tips in there also.
#5
so initial values are set through a basic table as string, array or csv, and the Notification messages supply the additional functionality of adding data, etc ( at least it appears that way)

thanks


Forum Jump:


Users browsing this thread: 1 Guest(s)