Powinieneś użyć TreeMode = 3
Kod:
// typy kolumn w MxGrid
#define ftString 0
#define ftInt 1
#define ftLong 16
#define ftMoney 2
#define ftDate 3
#define ftBitmap 17
#define ftCheck 7
#define ftDrop 128
#define COL_ROOT_ID 1
#define COL_PARENT_ID 2
#define COL_NAME 0
#define EC_DROPLISTITEM 35
dispatch Grid
//----
int Sub AddColumn(dispatch g, string ColName, int ColWidth, int ColType, int ColSize, int ColHidden, int ColLocked)
//----
int col
G.ColumnCount = G.ColumnCount + 1
col = G.ColumnCount - 1
G.Columns(col).Name = ColName
G.Columns(col).Width = ColWidth
G.Columns(col).FieldType(ColType,ColSize)
G.Columns(col).hidden = ColHidden
G.Columns(col).Locked = ColLocked
endsub
//----
int Sub AddRow(dispatch g, int root_id, int parent_id, string nazwa)
//----
dispatch dRow
// dodanie wiersza
dRow = g.InsertRow(-1)
dRow.Value(COL_NAME) = nazwa
dRow.Value(COL_ROOT_ID) = root_id
dRow.Value(COL_PARENT_ID) = parent_id
// ustawienie drzewa
g.Execute(51,COL_ROOT_ID,COL_PARENT_ID)
endsub
//----
int sub OnCommand(int id, int msg)
//----
int i,k
if msg==0 && id==0 then
grid.columncount = 0
grid.treemode = 3
AddColumn(grid, "nazwa", 100, ftString,200, 0, 1)
AddColumn(grid, "root_id", 100, ftLong,200, 0, 1)
AddColumn(grid, "parent_id", 100, ftLong,200, 0, 1)
for i = 1 to i > 10
for k = 0 to k > 10
AddRow(grid, i, k, using "wiersz %3.3d:%3.3d",i,k)
next k
next i
endif
endsub
FORM "Przykład drzewa", 1000,800
BUTTON "Anuluj",5,740,80,25,-1
CONTROL "grid",grid,5,5,985,730
int rv = ExecForm(OnCommand)
wyremuj na chwilę linię
Kod:
g.Execute(51,COL_ROOT_ID,COL_PARENT_ID)
wtedy zrozumiesz jak to działa
Załącznik:
mxgrid01.jpg [ 41.23 KiB | Przeglądany 3134 razy ]