473,407 Members | 2,306 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,407 software developers and data experts.

How do I scroll DataGrid to specified row index?

I want to know how to scroll a DataGrid so that a specific row index will be
visible to the user?
Nov 16 '05 #1
5 13272
Us the CurrentRowIndex member to set the row you want visible.
"MrNobody" <Mr******@discussions.microsoft.com> wrote in message
news:22**********************************@microsof t.com...
I want to know how to scroll a DataGrid so that a specific row index will
be
visible to the user?

Nov 16 '05 #2
Hi,

I'm trying to do auto scroll for my DataGrid, but each absolution I find
steal the focus to the DataGrid.
I also tried your suggestion using the CurrentRowIndex, but it also steals
the focus.

See my post regarding the other solution I tried:
http://msdn.microsoft.com/newsgroups...d-84a7b701329b
Can you tell how to do auto scrolling without stealing the focus?
--
Thanks
Sharon
Feb 7 '06 #3
Hi Sharon,

Thanks for your post.

I am not sure why SendMessage does not work for you. As we negotiated in
the original post, this solution should work for you.(Actually, it works
well on my side.) If not, can you show me a little sample to demonstrate
the problem?

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.

Feb 8 '06 #4
I have this ElementsDataGrid class which is in ElementList class:

public class ElementList : System.Windows.Forms.UserControl
{
private class ElementsDataGrid : System.Windows.Forms.DataGrid
{
internal void ScrollToRow(int aRowNum)
{
this.GridVScrolled(this, new
ScrollEventArgs(ScrollEventType.LargeIncrement, aRowNum));
}
}

private bool m_autoScroll;
private InfraControls.ElementList.ElementsDataGrid m_DataGrid;

[Description("Determines whether the grid will scroll down when a new row
is added."),
Category("Layout")]
public override bool AutoScroll
{
get { return m_autoScroll; }
set { m_autoScroll = value; }
}

public void SetDataSource(DataView data)
{
m_DataGrid.DataSource = data;
data.AllowNew = false;
}

private void DoAutoScroll()
{
if( m_autoScroll )
{
m_DataGrid.ScrollToRow((m_DataGrid.DataSource as DataView).Count-1);
}
}

private void AddDefects(object aSender, ArrayList aDefectRows)
{
DoAutoScroll();
}
}

Defects are added to the DataSet, causing the ElementsDataGrid to be added
with more rows and invoking the AddDefects() that invoke the DoAutoScroll().
And the DoAutoScroll() is invoked causing the vertical scrollbar of the
ElementsDataGrid to move --> the focus is taken to the ElementsDataGrid. And
this is the problem I wish to avoid.

The code is larger then what I have posted in here, I couldn’t post all of
it in here (much too much). I hope this post can help resolving this problem.
-----
Thanks
Sharon
Feb 8 '06 #5
Sorry, my latest post was not correct. There is a bug which does not seems
to be of my own code.
See
http://msdn.microsoft.com/newsgroups...e-5fc250c11468

Feb 16 '06 #6

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

Similar topics

4
by: Bill Sonia | last post by:
It seems whenever I set a DataGrid.DataSource = DataTable (vb.net) to populate a datagrid, the scroll bars on the datagrid default to disabled. And the only way I can get them to enable is to...
2
by: GrantS | last post by:
I am trying to convert the VB.Net code example povided by http://authors.aspalliance.com/JimRoss/Articles/MaintainScrollPos.aspx into C# (ASP.Net)without success. No errors are thrown in the VB...
2
by: Boaz Ben-Porat | last post by:
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...
1
by: Gidi | last post by:
hello i have a DataGrid table and by the help of Adnan, here in the forum, i have the Mouse_up Event that by Clicking a row on the dataGrid it's selectes the whole ro the problem is when i'm...
9
by: tshad | last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is filled? I have a bunch of DataGrids that get displayed nested inside a DataList. The datagrid looks like: ...
4
by: simchajoy2000 | last post by:
Hi, I have a form containing a datagrid where users can enter in their specified information for each row and column. Behind the scenes I have a sub which handles datagrid.CurrentCellChanged...
1
by: jeguillo | last post by:
I am trying to retrieve the text within each cell in a datagrid in order to change the color of each cell, depending on the value within that cell. This works fine on the cells that are bound...
0
by: Greg | last post by:
I've made a datagrid multiline (for anyone interested, I used an adaptation of the code at http://64.78.52.104/FAQ/WinForms/FAQ_c44c.asp). This has introduced a very serious issue: the vertical...
0
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.