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.

DataGridView ScrollBars

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chuck@newsgroup.nospam - 15 Jan 2006 17:23 GMT
Is their a way to determine if the DataGridView Scrollbars are
visible?
Is there a way to be notfied when their visible property has changed?

thanks,

p.s. this doesn't work for the datagridview for some reason.

 [DllImport("User32", CharSet = CharSet.Auto)]
       private static extern int GetWindowLong(IntPtr hWnd, int
Index);

       private const int GWL_STYLE = (-16);
       private const int WS_VSCROLL = 0x200000;
       private const int WS_HSCROLL = 0x100000;

       bool HasHorizontalScrollbar(Control ctrl)
       {
           return (GetWindowLong(ctrl.Handle, GWL_STYLE) &
WS_HSCROLL) != 0;
       }

       bool HasVerticalScrollbar(Control ctrl)
       {
           return (GetWindowLong(ctrl.Handle, GWL_STYLE) &
WS_VSCROLL) != 0;
       }
"TerryFei" - 16 Jan 2006 07:13 GMT
Hi kh,
Thanks for your post.

There are 2 types of Scrollbars:
1. Scrollbar that is created by WS_VSCROLL or WS_HSCROLL window style.
2. Scrollbar control, which is the child control of the parent control.
DataGridView uses the second type of Scrollbar. So we should enumerate
DataGridView’s child controls, then check to see if this scroll bar is
visible. Sample code sinppet listed below:

private void button1_Click(object sender, EventArgs e)
{
   for (int i = 0; i < this.dataGridView1.Controls.Count; i++)
   {
       if (this.dataGridView1.Controls[i] is VScrollBar)
       {
           if (this.dataGridView1.Controls[i].Visible)
           {
               MessageBox.Show("VScrollBar is visible");
           }
       }
       if (this.dataGridView1.Controls[i] is HScrollBar)
       {
           if (this.dataGridView1.Controls[i].Visible)
           {
               MessageBox.Show("HScrollBar is visible");
           }
       }
   }
}

This code snippet works well on my side. Hope it helps

Best regards,
Terry Fei

Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
>From: Chuck@newsgroup.nospam
>Subject: DataGridView ScrollBars
[quoted text clipped - 9 lines]
>Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
>Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.windowsforms.controls:26442
>X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms.controls
>
[quoted text clipped - 25 lines]
>WS_VSCROLL) != 0;
>        }
Chuck@newsgroup.nospam - 21 Jan 2006 02:42 GMT
perfect, thanks

>Hi kh,
>Thanks for your post.
[quoted text clipped - 79 lines]
>>WS_VSCROLL) != 0;
>>        }
"Jeffrey Tan[MSFT]" - 23 Jan 2006 05:55 GMT
You are welcome

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

"Jeffrey Tan[MSFT]" - 18 Jan 2006 07:55 GMT
Hi Chuck,

Does my colleague Terry's reply make sense to you? If you still need any
help, please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights

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.