Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Code Samples & Tips
Home Register FAQ Members List 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: 2,806
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: Door library (Beta) - Special library

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, 89 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: 575
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
no event changingselected cell in a table? moharj Bug Reports 5 02-02-2008 05:41 PM
unassign event paul j Questions & Help Needed 2 12-15-2007 02:02 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 & Help Needed 3 08-29-2007 10:29 AM
Calendar event Rioven Questions & Help Needed 7 08-28-2007 07:00 AM


All times are GMT. The time now is 04:55 AM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0