Width in table with XML

rmschreuder

Member
Licensed User
Hi Peeps,

Setting columnwidth in a table (TblD) in this code is does not work:
All columns stay equally wide.....
:BangHead:

bestandsnaam="\Opslagkaart\rmsgolf\rmsafstanden.xml"
TblD.LoadXML(bestandsnaam)
TblD.ColWidth(TblD.ColName(0))=65
TblD.ColWidth(TblD.ColName(1))=65
TblD.ColWidth(TblD.ColName(2))=35
TblD.ColWidth(TblD.ColName(3))=150
TblD.Visible=True
TblD.Refresh
FrmGem.Refresh


Any suggestions anyone???
 

mjcoon

Well-Known Member
Licensed User
TblD.LoadXML(bestandsnaam)

I've only used LoadCSV() (and with no header embedded in the file), so I don't have experience of the detail of LoadXML(), but I see that it sets up the column types and presumably the names. Have you confirmed that there are names? Would the code behave as you see if the names were null?

(I've just added a SaveXML() to my code in addition to the SaveCSV(), and I see that the XML has the column names but not the widths.)

I haven't had a problem with changing a column width to zero (and back) while the table is loaded...

Mike.
 

rmschreuder

Member
Licensed User
Ok, thx Mike,

I will look into that.
Are the widths of columns saved if you use saveCSV method?

mike (as well)
 

klaus

Expert
Licensed User
Longtime User
Hi Mike,

In CSV and XML files, the column widths are not saved. If you want to save them you must do it in a separate file. Could be interesting when the user has changed the width and wants to get the same at the next run of the program.

It looks strange that your column widths are all the same.
I have tried it with the attached test program, and it works.

Could you, perhaps, post your code so we could have a closer look at.

Why do you use XML files? Loading CSV files is faster.

Best regards.
 

Attachments

  • TableColWidth.sbp
    1.7 KB · Views: 168

rmschreuder

Member
Licensed User
Well,

I decided to switch to csv files and loadCSV as method.
Then the width of a table is settable. So I guess it is a bug, which only is there after using method LoadXML.

Answer to mjcoon: Yes there are columns; at least I see the columnheaders after loading with the correct names.

Another table problem:

I want to use the table object with different files, so I use:


If TblD.ColCount=0 Then Return
TblD.Clear
For n=0 To TblD.ColCount-1
TblD.RemoveCol(TblD.ColName(n))
Next n



I get errors on this code (not always) which i don't understand...
Anyone got the answer?
I attach code & files.
You have to change the used path to the files according to your phone and make directory rmsgolf etcetera.

Mike

mike
 

Attachments

  • testtable.sbp
    1.5 KB · Views: 178
  • testtblfiles.zip
    671 bytes · Views: 176
Last edited:

klaus

Expert
Licensed User
Longtime User
In the For - Next loop you use the variable 'n' representing the column index. After each RemoveCol the indexes of the columns change, so when for example n=TblD.ColCount-1, this column doesn't exist any more.

Try this code:
For i=Table1.ColCount-1 To 0 Step -1
Table1.RemoveCol(Table1.ColName(n))
Next

In the program I posted in post #5 with:
For i=0 To Table1.ColCount-1
Table1.RemoveCol("Test"&i+1)
Next
it works because I remove the columns by their name and not by their column index.

Well I decided to switch to csv files and loadCSV as method.
Then the width of a table is settable then. So I guess it is a bug.
I don't know why you couldn't resize the column width in your program. In the sample program in post #5 it works also with XML files !

Best regards.
 
Last edited:

rmschreuder

Member
Licensed User
Ah, of course!!!!!

Thx Klaus, now I have an error free program!
I will not look into the columnwidthproblem anymore, because the xml files are larger!
You certainly do deserve your awards in my opinion...

Mike
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…