Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Code Samples & Tips Share your recent discoveries and ideas with other users.

Table - MouseDown event and more

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-06-2008, 05:43 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default Table - MouseDown event and more

Using the new Door library it is now possible to improve the Table control.
With the following code you can add a new event, the MouseDown event.
The HitTest sub will return the pressed row and column (along with the control's part type).

With this sub you can find the index of the first visible row (this issue was discussed several times in the forum).

You should include the door library: http://www.basic4ppc.com/forum/official-updates/2038-door-library-beta-special-library.html

The code is attached.
Code:

Sub Globals
    
End Sub

Sub App_Start
    Form1.Show
    obj.New1(
true)
    o.New1(
false)
    table1.AddCol(cstring,
"c1",50)
    table1.AddCol(cstring,
"c2",50)
    table1.AddCol(cstring,
"c3",50)
    
For i = 1 To 10
        table1.AddRow(i,i,i)
    
Next
    SetAlternateRowsColor(
"Table1",cSilver)
    AddMouseDownEvent(
"Table1")
    HitTest(
"Table1",35,30)
End Sub

Sub AddMouseDownEvent(TableName)
    obj.FromControl(TableName)
    event.New1(obj.Value,
"MouseDown")
End Sub
Sub event_NewEvent
    o.Value = event.Data
    HitTest(
"Table1",o.GetProperty("X"),o.GetProperty("Y"))
End Sub
Sub HitTest(TableName,x,y)
    obj.FromControl(TableName)
    o.Value = obj.RunMethod3(
"HitTest",x,"System.Int32",y,"System.Int32")
    
    ListBox1.Clear
    ListBox1.Add(
"X: " & x & " Y: " & y)
    ListBox1.Add(
"Row: " & o.GetProperty("Row"))
    ListBox1.Add(
"Column: " & o.GetProperty("Column"))
    ListBox1.Add(
"Type: " & o.GetProperty("Type"))
End Sub

Sub SetAlternateRowsColor (TableName,Color)
    
If CPPC Then Return 'devices do not support this method
    obj.FromControl(TableName)
    o.CreateNew(
"System.Drawing.Color" & o.System_Drawing)
    o.Value = o.RunMethod2(
"FromArgb",Color,"System.Int32")
    obj.Value = obj.GetProperty(
"TableStyles")
    obj.Value = obj.GetProperty2(
"Item",0)
    obj.SetProperty2(
"AlternatingBackColor", o.Value)
End Sub
Attached Files
File Type: sbp EnhancedTable.sbp (1.7 KB, 199 views)
Reply With Quote
  #2 (permalink)  
Old 04-07-2008, 05:55 PM
specci48's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Germany
Posts: 1,057
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Marvellous tip Erel.
Remembering some very old threads I think that a lot of "coders" will very pleased by this example.


specci48
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve table filter from the filtered table? LineCutter Questions (Windows Mobile) 1 09-08-2008 06:20 AM
event doubleclick and click on the cell (table object)... micro Questions (Windows Mobile) 2 08-19-2008 05:50 PM
no event changingselected cell in a table? moharj Bug Reports 5 02-02-2008 05:41 PM
MouseDown/Move/Up either in all Controls or not hiding from Form Woinowski Basic4ppc Wishlist 3 11-05-2007 11:36 AM
TreeView event magi6162 Questions (Windows Mobile) 3 08-29-2007 10:29 AM


All times are GMT. The time now is 09:51 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0