473,403 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Simulate horizontal scroll

Hi all

Is there a way to simulate a click on a scrollbar (horizontal) of a FataGrid
?

I need to programmatically scroll the grid to the right/left upon some
condition, when the total width of the grid columns is greater then the
grid`s rectangle.

TIA
Boaz Ben-Porat
DataPharm a/s
Denmark
Nov 15 '05 #1
2 7492
Hi Boaz,

Thanks for your post!

There is no direct method of DataGrid class to scroll the grid
programmatically, however, I have 2 indirect way to achieve this purpose:

1. Manually set a DataGrid.CurrentCell which is in a specific position:

//before the following operation, you will probably have to save the
Current DataGrid1.CurrentCell information in order to retrive them lately.

DataGrid1.CurrentCell = Nothing
DataGrid3.CurrentCell = New DataGridCell(targetXcell, targetYcell)
//The DataGrid1 will scroll to the position where the cell(targetXcell,
targetYcell) in the Client View.
2. Send Windows message(WM_HSCROLL) to the DataGrid object via
SendMessage() Win32 API

public enum MsgType
{
SB_LINELEFT = 0,
SB_LINERIGHT = 1,
SB_PAGELEFT = 2, //same value as SB_PAGEUP
SB_PAGERIGHT = 3, //same value as SB_PAGEDOWN
SB_THUMBPOSITION = 4,
SB_THUMBTRACK = 5,
SB_LEFT = 6,
SB_RIGHT = 7,
SB_ENDSCROLL = 8,
WM_HSCROLL = 0x00000114
}

[DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr
hwndChildAfter, String lpszClass, String lpszWindow);

[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, MsgType uMsg, int
wParam, int lParam);

...
//the horizonal scroll bar's classID
IntPtr hHScroll = FindWindowEx(dataGrid1.Handle, (IntPtr)0,
"WindowsForms10.SCROLLBAR.app3", null);
IntPtr hVScroll = FindWindowEx(dataGrid1.Handle, hHScroll,
"WindowsForms10.SCROLLBAR.app3", null);

SendMessage(dataGrid1.Handle, MsgType.WM_HSCROLL,
(int)MsgType.SB_PAGERIGHT,(int)hHScroll);
SendMessage(dataGrid1.Handle, MsgType.WM_VSCROLL,
(int)MsgType.SB_PAGERIGHT,(int)hVScroll);

Hope it helps!

Gary Chang
Microsoft Online Partner Support
Get Secure! – www.microsoft.com/security
This posting is provided "AS IS" with no warranties,and confers no rights.
--------------------
| From: "Boaz Ben-Porat" <bo***@datapharm.dk>
| Subject: Simulate horizontal scroll
| Date: Thu, 9 Oct 2003 16:41:53 +0200
| Lines: 15
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| Message-ID: <OI*************@TK2MSFTNGP11.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: 195.215.64.74
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:190248
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Hi all
|
| Is there a way to simulate a click on a scrollbar (horizontal) of a
FataGrid
| ?
|
| I need to programmatically scroll the grid to the right/left upon some
| condition, when the total width of the grid columns is greater then the
| grid`s rectangle.
|
| TIA
| Boaz Ben-Porat
| DataPharm a/s
| Denmark
|
|
|

Nov 15 '05 #2
Here are some methods to scroll the grid:

Subclass datagrid and check the following methods:

public void scrollToBottom() {
int rowCount = this.BindingContext[this.DataSource,
this.DataMember].Count;
this.GridVScrolled(this, new
ScrollEventArgs(ScrollEventType.LargeIncrement,row Count -1));
}

public void scrollRight(int pos) {
this.GridHScrolled(this, new
ScrollEventArgs(ScrollEventType.SmallIncrement,pos ));
}

public void scrollLeft(int pos) {
this.GridHScrolled(this, new
ScrollEventArgs(ScrollEventType.SmallDecrement,pos ));
}

v-******@online.microsoft.com (Gary Chang [MSFT]) wrote in message news:<t8**************@cpmsftngxa06.phx.gbl>...
Hi Boaz,

Thanks for your post!

There is no direct method of DataGrid class to scroll the grid
programmatically, however, I have 2 indirect way to achieve this purpose:

1. Manually set a DataGrid.CurrentCell which is in a specific position:

//before the following operation, you will probably have to save the
Current DataGrid1.CurrentCell information in order to retrive them lately.

DataGrid1.CurrentCell = Nothing
DataGrid3.CurrentCell = New DataGridCell(targetXcell, targetYcell)
//The DataGrid1 will scroll to the position where the cell(targetXcell,
targetYcell) in the Client View.
2. Send Windows message(WM_HSCROLL) to the DataGrid object via
SendMessage() Win32 API

public enum MsgType
{
SB_LINELEFT = 0,
SB_LINERIGHT = 1,
SB_PAGELEFT = 2, //same value as SB_PAGEUP
SB_PAGERIGHT = 3, //same value as SB_PAGEDOWN
SB_THUMBPOSITION = 4,
SB_THUMBTRACK = 5,
SB_LEFT = 6,
SB_RIGHT = 7,
SB_ENDSCROLL = 8,
WM_HSCROLL = 0x00000114
}

[DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr
hwndChildAfter, String lpszClass, String lpszWindow);

[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, MsgType uMsg, int
wParam, int lParam);

...
//the horizonal scroll bar's classID
IntPtr hHScroll = FindWindowEx(dataGrid1.Handle, (IntPtr)0,
"WindowsForms10.SCROLLBAR.app3", null);
IntPtr hVScroll = FindWindowEx(dataGrid1.Handle, hHScroll,
"WindowsForms10.SCROLLBAR.app3", null);

SendMessage(dataGrid1.Handle, MsgType.WM_HSCROLL,
(int)MsgType.SB_PAGERIGHT,(int)hHScroll);
SendMessage(dataGrid1.Handle, MsgType.WM_VSCROLL,
(int)MsgType.SB_PAGERIGHT,(int)hVScroll);

Hope it helps!

Gary Chang
Microsoft Online Partner Support
Get Secure! ? www.microsoft.com/security
This posting is provided "AS IS" with no warranties,and confers no rights.
--------------------
| From: "Boaz Ben-Porat" <bo***@datapharm.dk>
| Subject: Simulate horizontal scroll
| Date: Thu, 9 Oct 2003 16:41:53 +0200
| Lines: 15
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| Message-ID: <OI*************@TK2MSFTNGP11.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: 195.215.64.74
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:190248
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Hi all
|
| Is there a way to simulate a click on a scrollbar (horizontal) of a
FataGrid
| ?
|
| I need to programmatically scroll the grid to the right/left upon some
| condition, when the total width of the grid columns is greater then the
| grid`s rectangle.
|
| TIA
| Boaz Ben-Porat
| DataPharm a/s
| Denmark
|
|
|

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nishant | last post by:
I have a combo box with a horizontal scroll bar. (Used SetHorizontalExtent) The dropdown with horizontal scroll bar works fine when I have more items in the dropdown list. However when the...
14
by: Dave | last post by:
My web site is not particularly theme-based, but it contains an Art Gallery I'd like to display in a different perspective. I would like to horizontally scroll it, rather than vertically - as if...
4
by: justdummy | last post by:
Hi, I am struggling with a problem for sometimes. I need to display a table in a html and if the height of the table goes beyond 200 px then a vertical scrollbar should alone appear without any...
1
by: Jeremy Chapman | last post by:
I've got a grid inside a div so that it's got scroll bars around it. What I want to do is have the header row fixed at the top, so that the vertical scroll bars scroll just the data rows of the...
3
by: sumit | last post by:
Hi, I made a data grid vertically as well as horizontal scrollable as number of columns are very large!! But when i scroll horizontally then header is not visible as it also gets scrolled...
2
by: Eduard | last post by:
I have a ASP.Net datagrid wrap in the following div: <DIV id="divPart2" style="OVERFLOW: hidden">. Another div controls the horizontal scrolling: <DIV id="scroll1" style="OVERFLOW: scroll;...
3
by: lolo | last post by:
hello. happy new year. I'm trying to build a website for my wife and she is adament on having a horizontal thumbnail scrolling div. great. I have a good vertical scrolling thing, but can't...
1
by: amuven | last post by:
Hi All, I need to put a horizontal scroll bar for 4 cells alone where my first cell in table should not contain any horizontal scroll bar . In clear, let us say there are 5 columns in my...
1
by: newbie009 | last post by:
How can I disable horizontal scroll in textbox for FireFox? Right now 1 textbox has vertical scroll and other textbox has horizontal scroll. It only looks like this on FireFox but it looks ugly....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.