![]() |
|
|||||||
| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Code Samples & Tips Share your recent discoveries and ideas with other users. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
Using the attached code you can turn a regular table to an editable table.
The code uses the Door library to add a MouseDown event to the table control. After calculating the cell upper left corner position, a panel with one textbox and one accept button is shown. ![]() I hope you'll find this code useful. It is more complex than it may seem because rows and columns could be partially or fully hidden. Edit: V1.10 - Using the new modules feature all the editable code was moved to a separate module. It is now possible to easily use more than one editable table in the same application. Two new optional features: - Validator - a sub that is called before changing any value and allows canceling the change if required. - For each column you can choose whether to show a textbox or a combobox and choose the combobox values. See this post for more details about using ComboBoxes: Combobox in editable table Edit: V1.02 is attached. The edit panel will now disappear when one of the scrollbars is scrolled. The solution is based on agraham's code in post #7. Edit: V1.01 is attached. It fixes the bug in post #4. |
|
||||
|
There are two subtle reasons why the timer is required.
MouseDown event occurs before SelectionChanged event. At the end of SelectionChanged event the focus returns to the table. So if we want to move the focus to the textbox we need to use the timer. The second reason happens when you click on a partially hidden cell. The table automatically scrolls the horizontal and/or vertical scrollbar in such way that the cell will be fully visible. This rearrangement occurs after MouseMove event. We must make the position calculations only after this rearrangement so again the timer is necessary. |
|
||||
|
Quote:
Quote:
|
|
||||
|
Thanks agraham.
I've fixed this bug and updated the source code. This is the change: Code:
Sub CalcColumnPosition (colNumber)
x = editTable.x
o.Value = obj.RunMethod3("HitTest",x,"System.Int32",editTable.y,"System.Int32")
If o.GetProperty("Type") = "None" Then editTable.y = editTable.y - editTable.rowHeight
...
|
|
|||
|
Hi Erel,
How to catch the scroll bar properties on mousedown event on table? I just want to disable the scroll bars during input so that the input panel will not be displaced from the selected cell when scroll bars are moved.
__________________
Rioven Sony Ericsson XPERIA X1i WM6.1 480x800 Display Resolution with QWERTY keyboard |
|
||||
|
Quote:
Code:
oh.New1(false)
ov.New1(false)
obj.FromControl(TableName)
o.Value = obj.GetProperty("Controls")
oh.Value = o.GetProperty2("Item",0) ' 0 = hscrollbar, 1 = vscrollbar
ov.Value = o.GetProperty2("Item",1) ' 0 = hscrollbar, 1 = vscrollbar
oh.SetProperty("Enabled", false)
ov.SetProperty("Enabled", false)
Code:
txtEdit.SelectionLength = StrLength(txtEdit.Text)
oh.SetProperty("Enabled", false)
ov.SetProperty("Enabled", false)
txtEdit.Focus
Last edited by agraham : 06-27-2008 at 09:53 AM. |
|
|||
|
Hi Erel, Thanks very much for this very useful code. also thanks to agraham for other inputs.
Alternative updating table cell content which is... just leaving the cell. This is more of my preference or maybe to some others. I've made slight modifications which get rid of the accept button. I've tested on device and found it works. maybe need to test with other devices. here are what I did... I have deleted the 'btnAccept' button and made some minor panel and textbox size adjustments... then added ... Sub txtEdit_lostFocus btnAccept_click End Sub and also added 'btnAccept_click' on scroll bars I hope I did it correctly...Please let me know Regards, Rioven EDIT: updated file... see next post...
__________________
Rioven Sony Ericsson XPERIA X1i WM6.1 480x800 Display Resolution with QWERTY keyboard Last edited by Rioven : 09-03-2008 at 08:29 AM. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Editable table | davelew1s | Questions & Help Needed | 6 | 06-18-2008 04:06 PM |
| Using rapi from desktop to copy file from device to desktop | sunnyboyj | Questions & Help Needed | 9 | 02-08-2008 12:40 PM |
| XYCalc -graphs an equation or editable table of figures in regular, bar or pie chart | HarleyM | Code Samples & Tips | 2 | 11-24-2007 08:21 AM |
| Editable Table | RandomCoder | Code Samples & Tips | 3 | 06-29-2007 11:17 PM |
| editable table ? | giannimaione | Questions & Help Needed | 2 | 05-13-2007 11:34 AM |