Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / January 2006

Tip: Looking for answers? Try searching our database.

Windows Form - Scrolling (.NET 2003)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JumpingMattFlash - 18 Jan 2006 15:01 GMT
I'm trying to create a windows form application using .NET 2003

Specifically I'm trying to create a scrollable portion within my form. This
portion is to be populated with what is in effect a table (or more
specifically a contact list) which is taken from a webservice.
Ideally i want to be able to scroll through the list of clickable elements
which would then open a new form when clicked.

My knowledge of windows forms is very poor as I've dealt mainly with ASP.NET
for last year so try to explain any ideas as fully as you can.

So far i've created a label control and a HScroll bar. If I set the label
AutoSize to false, the label does not scroll to the elements which appear
outside of the region, if i set the autosize to true, for some reason only
the first line is displayed.

Code:Private Sub frmMainForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim hsb As Single = CSng(scrlVerticalScroll.Height - lblContactList.Height)
      Dim ticks As Single = CSng(scrlVerticalScroll.Maximum -
scrlVerticalScroll.Minimum)

      vScrollMultiplier = hsb / ticks
End Sub

Code: Private Sub scrlVerticalScroll_Scroll(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.ScrollEventArgs) Handles
scrlVerticalScroll.Scroll
      vAbsPos = CSng(scrlVerticalScroll.Value - scrlVerticalScroll.Minimum)
      lblContactList.Top = scrlVerticalScroll.Bottom -
CInt(vScrollMultiplier * vAbsPos) - lblContactList.Height
  End Sub
 

Code:Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLogin.Click

'Snip
          Dim ContactRow As DataRow
          lblContactList.Text = ""
          For Each ContactRow In DataSet.Tables(0).Rows
              lblContactList.Text &= ContactRow.Item(0) &
ContactRow.Item(1) & vbCrLf
              MsgBox(ContactRow.Item(0))
          Next
          lblContactList.AutoSize = True
      End If

  End Sub

Thanks in Advance,
Signature

=============
VB .NET Developer
http://www.rocketscience.uk.com

Bob Powell [MVP] - 19 Jan 2006 18:30 GMT
I think you'd be better off populating a ListView with your contact info and
responding to the SelectedIndexChanged and / or DoubleClick events.

If you need a specific look for you contact info consider a ListView with
one column and do your own custom item drawing.

Signature

Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

> I'm trying to create a windows form application using .NET 2003
>
[quoted text clipped - 51 lines]
>
> Thanks in Advance,

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.