?
Solved

datagridview question

Posted on 2006-11-01
4
Medium Priority
?
690 Views
Last Modified: 2012-08-13
Suppose I have a datagridview with hundreds of row.
How can I programatically select a cell (that is out of the display region) and make it visible and center it in the display region?
0
Comment
Question by:michellechan57
4 Comments
 
LVL 10

Expert Comment

by:anv
ID: 17855601
Can you elaborate it a bit more?
0
 

Author Comment

by:michellechan57
ID: 17855961
Thanks.
This is a windows form develop using VS2005.
The datagridview is bounded and let say it has hundreds of record.
The screen can only show the first 20 initially.
After a search operation, I wanted to display a record that is not in the first 20 (let say the record found is the 100th).
I want to be able to "move" this 100th record to the center of the screen and be visible to the user.
0
 
LVL 11

Accepted Solution

by:
anyoneis earned 2000 total points
ID: 17856014
How about setting FirstDisplayedCell?

From docs:

The following code example illustrates how to ensure that the current cell is visible after sorting. This code works only with an unbound DataGridView control. With a DataGridView control bound to an external data source, the current cell is not automatically persisted when sorting.

To run this example, paste the following code into a form that contains a DataGridView named dataGridView1. In C#, you must also connect the Sorted event to the event handler.

Visual Basic  Copy Code
Private Sub dataGridView1_Sorted(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles dataGridView1.Sorted

    Me.dataGridView1.FirstDisplayedCell = Me.dataGridView1.CurrentCell

End Sub

 
C#  Copy Code
private void dataGridView1_Sorted(object sender, EventArgs e)
{
    this.dataGridView1.FirstDisplayedCell = this.dataGridView1.CurrentCell;
}

 
0
 
LVL 5

Expert Comment

by:t_itanium
ID: 17856146
hi

try this:


foreach(DataGridItem item in yourDataGrid.Items)  
{
       //Search for your record
       //if(this is the record)
       // {
       //            do somthing (you can use item.Cells[row index] to see info
       //             at specified cell)
       //}
}

0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question