10-13-2020 01:22 AM
Hello,
I have a problem working with tables.
I need to solve this problem and I don't know how to program it, can't anyone help me?
1) Delete Row - I need to delete the entire selected row. So far, I have only been able to delete the first line.
2) Restore - If I delete something, I would like to restore it back when I'm wrong.
3) Add a row - I would like to add an entire row to the end of the table.
4) Sorts by - I would like to sort the whole table alphabetically and how to load (Routes)
5) Scroll up and back one line at a time and jump to the end of the table and the arrow to the beginning of the table.
I can't deal with this problem, thank you very much for your help and I'm attaching the project.
10-13-2020 08:33 AM
You've mocked up a very complex project with a lot of table features. I would recommend starting very simple, perhaps only support the add/delete rows.
I've worked with tables a lot in many of my projects. They are powerful, but very cumbersome to manipulate, particularly if you need to keep track of row contents in local memory.
In your case, wanting to "remember" the contents of a row to effectively undo a delete is where you will need to keep track of the table in your own memory. I would recommend some sort of struct that defines the column fields. Then make an array of this struct, equal in the number of rows.
As to adding rows in specific indexes, this is supported. InsertTableRows with the index is what you want.
10-13-2020 08:36 AM
I can point you to the correct commands to use and to some relevant example.
1. DeleteTableRows is the command to use in this case
2. You can copy table data to clipboard before deleting them and restore them from the clipboard to roll them back. ClipboardPutTableVals and ClipboardGetTableVals are the commands to use
3. InsertTableRows is useful in this case. Look at colview.cws example
4. SortTableCells: an example is the same project as above
5. Use SetCtrlAttribute with ATTR_FIRST_VISIBLE_ROW and some effort in coding
Generally speaking, all these informations can be found in the help: right click on the table control in the UIR editor and choose Control Help to access the help page for table controls: Programming with Table Controls is the page where to found all relevant informations on coding.
10-13-2020 08:42 AM
I second Roberto's advice. The help is truly amazing. Also, look for the sample projects linked right there in the help window. They are great!
There's no other way to gain this knowledge but to just jump in. I spent many hours learning tables, but it's worth it.
11-05-2020 12:58 AM
Greetings Roberto Bozzolo 🙂
I apologize for the late response.
1) I've already figured this out, I knew the "DeleteTableRows" command, of course, but it didn't delete the whole table, but only one part of it, so I had to add a pointer to the structure.
2) These commands might work, but I don't know how to use them.
3) This example helped me, thank you.
4) The example also contains sorting, I haven't gotten to that yet.
5) Can I find an example somewhere? How is this programmed?
Thank you for your advice.
Have a nice day
11-05-2020 08:14 AM
1) I'm confused by the solution you took. Can you explain further?
The function DeleteTableRows already has a built-in ability to delete all table rows, as per its numberOfRows parameter: "To delete all items from rowIndex to the end, enter –1."
11-05-2020 05:30 PM
2) To save part of a table you need to call ClipboardPutTableVals passing the appropriate Rect structure defining the area of interest. MakeRect can be of help in this case.
The help describes how data is saved to the clipboard.
ClipboardGetTableVals works the opposite way.
11-10-2020 05:31 AM
Yes, it deleted the row, but only one of her cells. The whole row consists of 14 cells. I had to use the "GetActiveTableCell" function where he then deleted the whole row.
11-10-2020 05:08 PM
This is not the way it should work: can you post a reduced project that shows this abnormal behavior?
11-10-2020 11:11 PM
Point selectedRange;
GetActiveTableCell (panelHandle, PANEL_TABLE, &selectedRange);
DeleteTableRows (panelHandle, PANEL_TABLE, selectedRange.y, 1);
5) I would like to assign the "Page Down" key and the "Page UP" key to a specific button. Is there any way to do this?