|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
FXTable insert/delete rowHi all,
I'm just starting studing FOX-1.6.36 and I have a question regarding FXTable. In particular, it's not really clear to me the "insert row"/"delete row" behaviour. Please consider this change in the example code table.c: // Deleted long TableWindow::onTableDeleted(FXObject*,FXSelector,void* ptr) { FXTableRange *tr=(FXTableRange*)ptr; FXTRACE((10,"SEL_DELETED fm.row=%d, fm.col=%d to.row=%d, to.col=%d\n",tr->fm.row,tr->fm.col,tr->to.row,tr->to.col)); FXint r,c,nr,nc; nr=table->getNumRows(); nc=table->getNumColumns(); for(r=0; r<nr; r++) { for(c=0; c<nc; c++) { table->setItemText(r,c,"r_ridim:"+FXStringVal(r+1)+" c_ridim:"+FXStringVal(c+1)); } } return 1; } what happens is that execution of the code above is done before row deletion while the same code in the insert row code is (correctly to me) done after row insertion. for example if I delete row 4 I got traces: [2176] SEL_DELETED fm.row=4, fm.col=0 to.row=4, to.col=6 [2176] delete item r_ridim:5 c_ridim:1 [2176] delete item r_ridim:5 c_ridim:2 [2176] delete item r_ridim:5 c_ridim:3 [2176] delete item r_ridim:5 c_ridim:4 [2176] delete item r_ridim:5 c_ridim:5 [2176] delete item r_ridim:5 c_ridim:6 [2176] delete item r_ridim:5 c_ridim:7 so I got a table switching from element r_ridim:4 c_ridim:1 to element r_ridim:6 c_ridim:1 that is not what I want. Where I'm wrong? Thanks and regards, Mad Max |
|
|
Re: FXTable insert/delete rowOK, I got no answers ... one of the possible reasons is that I maybe didn't explain enough ... trying again ...
I would like to exexute this code if I delete or insert a row in a table: for(r=0; r<nr; r++) { for(c=0; c<nc; c++) { table->setItemText(r,c,"r_ridim:"+FXStringVal(r+1)+" c_ridim:"+FXStringVal(c+1)); } } So the result should be more or less the text "r_ridim(number of row)+c_ridim(number of column)" in every cell of the table. What I get putting this code in the insert and delete row functions (as in the example in the first message) is: insert a row: ok every cell is filled with correct text delete a row: every cell is filled with text but the one I deleted, i.e. if for example I delete the row number 4 then I got item "r_ridim:3 c_ridim:1" for row 3 column 1 and item "r_ridim:5 c_ridim:1" for row 4 column 1 instead of "item r_ridim:4 c_ridim:1 " ... Hope it is more clear now. Thanks again for your attention and eventually :-) answers ... Regards, Mad Max |
|
|
Re: FXTable insert/delete rowOn Tuesday 09 June 2009, Mad Max wrote:
> > Hi all, > I'm just starting studing FOX-1.6.36 and I have a question regarding > FXTable. > In particular, it's not really clear to me the "insert row"/"delete row" > behaviour. > Please consider this change in the example code table.c: > > // Deleted > long TableWindow::onTableDeleted(FXObject*,FXSelector,void* ptr) > { > FXTableRange *tr=(FXTableRange*)ptr; > FXTRACE((10,"SEL_DELETED fm.row=%d, fm.col=%d to.row=%d, > to.col=%d\n",tr->fm.row,tr->fm.col,tr->to.row,tr->to.col)); > > FXint r,c,nr,nc; > > nr=table->getNumRows(); > nc=table->getNumColumns(); > > for(r=0; r<nr; r++) > { > for(c=0; c<nc; c++) > { > table->setItemText(r,c,"r_ridim:"+FXStringVal(r+1)+" > c_ridim:"+FXStringVal(c+1)); > } > } > > return 1; > } > > what happens is that execution of the code above is done before row deletion > while the same code in the insert row code is (correctly to me) done after > row insertion. > > for example if I delete row 4 I got traces: > > [2176] SEL_DELETED fm.row=4, fm.col=0 to.row=4, to.col=6 > [2176] delete item r_ridim:5 c_ridim:1 > [2176] delete item r_ridim:5 c_ridim:2 > [2176] delete item r_ridim:5 c_ridim:3 > [2176] delete item r_ridim:5 c_ridim:4 > [2176] delete item r_ridim:5 c_ridim:5 > [2176] delete item r_ridim:5 c_ridim:6 > [2176] delete item r_ridim:5 c_ridim:7 > > so I got a table switching from element r_ridim:4 c_ridim:1 to element > r_ridim:6 c_ridim:1 that is not what I want. > > Where I'm wrong? > > Thanks and regards, > Mad Max > OK, Sorry I didn't reply sooner. Basically, SEL_DELETED is issued PRIOR to the items being deleted. When you re-initialize the contents of the table while inside the callback, the old cells are still there and are being overwritten with the new contents. Thus, the cells being actually deleted are the new values, not the old ones. Note, it says so in the documentation ;-) - Jeroen ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
| Free embeddable forum powered by Nabble | Forum Help |