Welcome Guest!
 VB Helper
 Previous Message All Messages Next Message 
VB Helper Newsletter  Rod Stephens
 Sep 25, 2009 14:30 PDT 

This morning I had a pleasant surprise: my book "Visual Basic 2010
Programmer's Reference" made an appearance on the top of Amazon's VB
books list. How they decide what's on top depends on page views not
sales but it was still nice.

Haven't seen "Beginning Database Design Solutions" there for a while ;-)
-
Apologies to the VB 6-only subscribers. I have a cool example but
haven't had the time to put it together and write it up. I'll try to get
to it for the next newsletter, I promise!

Have a great week and thanks for subscribing!
----------
Rod
RodSte-@vb-helper.com

Books To Keep: http://www.BooksToKeep.com
----------
*** Now Available ***

Beginning Database Design Solutions
http://www.amazon.com/exec/obidos/ASIN/0470385499/vbhelper/

Visual Basic 2008 Programmer's Reference
http://www.amazon.com/exec/obidos/ASIN/0470182628/vbhelper/
==========

    VB.NET Contents:
1. New HowTo: Draw text flipped vertically, horizontally, or both in
Visual Basic .NET
2. New HowTo: Keep track of ListView columns when the user reorders them
in Visual Basic .NET

    Both Contents:
3. New Links
==========
++++++++++
<VB.NET>
++++++++++
==========
1. New HowTo: Draw text flipped vertically, horizontally, or both in
Visual Basic .NET
http://www.vb-helper.com/howto_net_draw_flipped_text.html
http://www.vb-helper.com/HowTo/howto_net_draw_flipped_text.zip

Subroutine DrawFlippedText does all of the interesting work. It saves
the current graphics state and then sets up a transformation to properly
flip the text. It then calculates where it needs to draw the text so it
lands in the desired location. The routine then draws the text and
restores the original graphics state.


Public Sub DrawFlippedText(ByVal gr As Graphics, ByVal the_font As Font,
ByVal the_brush As Brush, ByVal x As Integer, ByVal y As Integer, ByVal
txt As String, ByVal flip_x As Boolean, ByVal flip_y As Boolean)
    ' Save the current graphics state.
    Dim state As GraphicsState = gr.Save()

    ' Set up the transformation.
    Dim scale_x As Integer = IIf(flip_x, -1, 1)
    Dim scale_y As Integer = IIf(flip_y, -1, 1)
    gr.ResetTransform()
    gr.ScaleTransform(scale_x, scale_y)

    ' Figure out where to draw.
    Dim txt_size As SizeF = gr.MeasureString(txt, the_font)
    If flip_x Then x = -x - txt_size.Width
    If flip_y Then y = -y - txt_size.Height

    ' Draw.
    gr.DrawString(txt, the_font, the_brush, x, y)

    ' Restore the original graphics state.
    gr.Restore(state)
End Sub

The main program calls this subroutine as in the following code.

DrawFlippedText(e.Graphics, the_font, Brushes.Red, 10, 10, "Flip X",
True, False)
==========
2. New HowTo: Keep track of ListView columns when the user reorders them
in Visual Basic .NET
http://www.vb-helper.com/howto_net_listview_track_column_order.html
http://www.vb-helper.com/HowTo/howto_net_listview_track_column_order.zip

If you allow the user reorder a ListView's columns, the underlying data
source is not modified. The display changes but the columns of data
don't.

As far as I know (correct me if I'm wrong), the ListView doesn't provide
a way to tell which column is where after they are rearranged. This
example keeps track of the original column indexes and titles. It stores
them in two collections:

Private m_ColumnIndexes As Collection
Private m_ColumnNames As Collection

When the program starts, it initializes these collections.

' Record the initial column names.
m_ColumnNames = New Collection()
For i As Integer = 0 To lvwBooks.Columns.Count - 1
    m_ColumnNames.Add(lvwBooks.Columns(i).Text)
Next i

' Record the initial column indexes.
m_ColumnIndexes = New Collection()
For i As Integer = 0 To lvwBooks.Columns.Count - 1
    m_ColumnIndexes.Add(i)
Next i

When the user reorders columns, the program catches the ListView's
ColumnReordered event and updates the collections so it knows where the
columns have moved.

' Update the column order.
Private Sub lvwBooks_ColumnReordered(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.ColumnReorderedEventArgs) Handles
lvwBooks.ColumnReordered
    Dim column_name As String = CStr(m_ColumnNames(e.OldDisplayIndex +
1))
    m_ColumnNames.Remove(e.OldDisplayIndex + 1)
    m_ColumnNames.Add(column_name, Before:=e.NewDisplayIndex + 1)

    Dim index As Integer = CInt(m_ColumnIndexes(e.OldDisplayIndex + 1))
    m_ColumnIndexes.Remove(e.OldDisplayIndex + 1)
    m_ColumnIndexes.Add(index, Before:=e.NewDisplayIndex + 1)

    ' Display the current name order.
    For i As Integer = 1 To m_ColumnIndexes.Count
        Debug.Write(CStr(m_ColumnNames(i)) & " ")
    Next i
    Debug.WriteLine("")

    ' Display the current index order.
    For i As Integer = 1 To m_ColumnIndexes.Count
        Debug.Write(CInt(m_ColumnIndexes(i)) & " ")
    Next i
    Debug.WriteLine("")
End Sub
==========
++++++++++
<Both>
++++++++++
==========
3. New Links
http://www.vb-helper.com/links.html

Tutors 4 Me
http://www.tutors4me.co.uk/default.aspx?pge=p_regions_ICT
Find UK based IT Tutors for local tutoring or online tutoring worldwide.

Free Online University (setup fee)
http://www.bin95.com/University/Index.htm
Office 2007, IT, computer, and other training.

CorelDraw VBA
http://corel-vba.awardspace.com/
Help using CorelDraw! with VBA.
==========
Archives:
    http://www.topica.com/lists/VBHelper
    http://www.topica.com/lists/VB6Helper
    http://www.topica.com/lists/VBNetHelper

Post questions at:
    http://www.topica.com/lists/VBHelperQA
	
 Previous Message All Messages Next Message 
  Check It Out!

  Topica Channels
 Best of Topica
 Art & Design
 Books, Movies & TV
 Developers
 Food & Drink
 Health & Fitness
 Internet
 Music
 News & Information
 Personal Finance
 Personal Technology
 Small Business
 Software
 Sports
 Travel & Leisure
 Women & Family

  Start Your Own List!
Email lists are great for debating issues or publishing your views.
Start a List Today!

© 2001 Topica Inc. TFMB
Concerned about privacy? Topica is TrustE certified.
See our Privacy Policy.