DEVBUZZ Homepage Review of Odyssey Software's free DataViewer control for eVB
 
Web www.devbuzz.com
  HOME PAGE
  All Articles
  Advertise
  Consulting

 Development
  Discuss - Forums
  Still in the box?
  .Compact Framework
  Code Snippets
  SQL Server CE
  Database
  MS Resources
 Stores
  Developer Controls
  Pocket PC Hardware
  Pocket PC Software
  Pocket PC Books
  .NET CF Books
  Book Reviews
  SPB SW Discounts
  RESCO SW Discounts
 DEVBUZZ Info
  About Us
  Help
  Join our email list
  Links & Ratings
  Press & Comments
  Pocket PC version
  Software Reviews
  Hardware Reviews
 Authors
  Authors
  Article Guide
  Competitions
 Resources
  Developers
  Register
  Login

  SPB Discounts!
 Columnists
  Rick Winscot
 Past Blast
  Personal Media Ctr
  Gizmobility
  eVB Legacy
  Old news
  Hosted Software
  Wireless
  Newsletters
  Carl Davis
  Upton Au

 Pocket PC Registry
  Join the registry
  View current list
 Current Poll
Are you converting to .NET Compact Framework?
Yes, it has changed my life!
No, I'm sticking with eVB
.NET CF what's that`?

Current results
3431 votes so far
 Recent Forum Threads [goto forums]

Get Computername
read... (67 hits)


Great aid to development productivity
read... (82 hits)


ThreadingTimer sample code
read... (143 hits)


Multithreading with .NET CF
read... (194 hits)


Moving from eMbedded Visual Basic to Visual Basic .NET
read... (166 hits)


.NET Compact Framework 2.0 Service Pack 2
read... (226 hits)


Transfer Data from SQL Server 2000 to SQL Server Compact Edition
read... (298 hits)


This protocol version is not supported
read... (236 hits)


Converting Lowercase to uppercase wont work
read... (203 hits)


Direct access to MS SQL Server 2000
read... (374 hits)


Creating SDF file in Desktop
read... (513 hits)


Winsock in CF.NET
read... (316 hits)


Using Pocket Outlook to submit HTML page form with MAILTO action
read... (420 hits)


Missing file "System.Data.PocketPC.asmmeta.dll"
read... (268 hits)


HP iPAQ hw6915 Serial Port Issue
read... (309 hits)


Info on the recent forum changes
read... (341 hits)


SqlServer tools from Redgate
read... (383 hits)


Arrow keys and Hardware navigation button
read... (393 hits)


O2 XDA lls pin sync cable to comport
read... (322 hits)


Creating dynamic folders on Pocket PC OS
read... (299 hits)

Custom Windows Mobile software development.
LBS Challenge 2007
LBS Challenge Eight previous NAVTEQ Global LBS Challenge® participants have received venture capital funding and nine past LBS Challenge winners have launched commercial applications on major wireless carriers. Register your non-commercial LBS application in the 2007 NAVTEQ Global LBS Challenge in one of three regions: Americas, Europe-Middle East-Africa (EMEA) or Asia-Pacific(APAC). You could win a share of $2 million in prizes. This could be your year.
Dream. Develop. Win.

Development | Starting Out

Review of Odyssey Software's free DataViewer control for eVB
Written by Pete Vickers  [author's bio]  [read 47599 times]
Edited by Derek

Download the code   Discuss this article   eVB Ver 3.0   

Page 1  Page 2  Page 3 

Briefly, we are passing in the row. If the absolute position of the recordset is not this row, we will move to that record. We then use the column-1 to get the field value. In our sample project, this routine is called 16 times, as we are displaying 8 rows and 2 columns. As we scroll down, the 'GetItemText' event is automatically fired.

I was a little concerned by this at first, as scrolling up and down would generate a lot of database activity, but in practice, it works well.

Our sample gives us another option though - we can use 'getrows'. Use the GetRows method to copy records from a Recordset object into a two-dimensional array. So, instead of rs.movenext, we use…

AvarTable = rs.GetRows

This gives us a 2 dimensional array containing all the records. Again, setting the dataview rowcount to the number of records fires the 'GetItemText' event. This time however, the code reads...

If IsArray(AvarTable) Then
Text = CStr(AvarTable(Column - 1, Row - 1) & "")
End If

Instead of going to the database for the records, we are reading them from our array. This will give us some advantages we will see later, and we will use in our other sample project.

So, we now know how to populate the listview. If you have had problems following my garbled explanation of how it works, do what I did - single step through the code. It all becomes much clearer then.

The DataViewer contains more properties and events than the listview. ‘Hands up’ all those who want to use 'tap and hold' in a listview. The DataViewer supports this through context menus. Simply set the contextmenu property to 'True', and hold down the stylus. The 'showcontextmenu' event fires.

Private Sub dvRecs_ShowContextMenu _
(ByVal X As Long, ByVal Y As Long)

Dim hWnd As Long
Dim intSelection As Long
On Error Resume Next

hWnd = GetFocus()
intSelection = ShowPopupMenu(hWnd, X, Y)
Select Case intSelection
Case 1
Edit_Record
Case 2
If bGetRows Then
MsgBox "Delete record: " _
& CStr(AvarTable(0, _
dvRecs.Selection - 1) & "")
Else
MsgBox "Delete record: " _
& GetRecordsetFieldValue _
(rs, SaveRow, SaveCol)
End If
Case 3
Total_Records
Case Else
End Select
frmMain.SetFocus
dvwRecords.SetFocus
End Sub

Public Function ShowPopupMenu(hWnd As Long, _
Left As Integer, Top As Integer) _
As Integer

Dim hMenu As Long
Dim lOption As Long
Dim iMenuItem As Integer

hMenu = CreatePopupMenu()

' Edit menu items
lOption = MF_ENABLED
AppendMenu hMenu, lOption Or MF_STRING, 1, _
"Edit"
AppendMenu hMenu, lOption Or MF_STRING, 2, _
"Delete"
AppendMenu hMenu, lOption Or MF_STRING, 3, _
"Total Records"

ShowPopupMenu = (TrackPopupMenuEx(hMenu, _
TPM_LEFTALIGN Or TPM_TOPALIGN _
Or TPM_RETURNCMD, Left / 15, _
Top / 15, hWnd, 0))

DestroyMenu hMenu
End Function

This will give us a context menu with 3 items, Edit, Delete and Total Records on it. To demonstrate the use of Edit, we simply move the data from our data viewer to our text fields, and make the frame visible. The 'OK' button simply makes the frame invisible, but could easily write back any changes to our record.

Delete records is a dummy item, but Total records allows us to get a total of the numeric fields in the DataViewer. This explains why we used the 'getrows' method earlier. To total up using the normal method of 'movenext', we need to use the procedure GetRecordsetFieldValue, which may (most probably will) involve reading records from the database. If we use 'getrows', we can simply total up using our array. Using the emulator, it takes approx 50 milliseconds. Using 'movenext' it takes approx 850 milliseconds to total up. This was using 1000 records.

Previous Page  Next Page 

Back to Starting Out | [Article Index]

 

Back to the top of the page.
Chris De Herrera's Windows CE Website Windows CE News & Information Source
Copyright ©2000-2007 by DEVBUZZ.COM, Inc., NJ. USA.MSDEVELOP