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

Scroll Pointer in DataGridView

I have some buttons that increment and decrement the index of a DataGridView.
The code below gets the updated index value. The code below highlights the
first column of the current row.

dataGridView1.CurrentCell = dataGridView1[0, index];

This is almost exactly what I want. I'd really prefer it if the code above
could highlight the entire row, rather than just the first column.

Any suggestions on how to modify the code above to highlight the current
row, rather than just the first column of the current row?

Thanks,
--
Randy
Jun 5 '06 #1
7 7679
Hi Randy,

Thanks for your pose!

You can set DataGridViewRow.Selected proerty to true to select certain row
in DataGridView. You can use DataGridView.Rows[index] to get the
DataGridViewRow reference.

Hope it helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 5 '06 #2
Here's what I started with. It works great, but only selects the first cell
in the row, rather than the entire row:

dataGridView1.CurrentCell = dataGridView1[0, index];

Here's what I came up with based on your suggestion:

DataGridViewRow row = dataGridView1.Rows[index];
row.Selected = true;

This really doesn't give me quite the same functionality, as it requres me
to keep track of the previously selected row, and set row.Selected = false.
Is there no implementation of CurrentRow that give the same functionality as
CurrentCell?

--
Randy
""Jeffrey Tan[MSFT]"" wrote:
Hi Randy,

Thanks for your pose!

You can set DataGridViewRow.Selected proerty to true to select certain row
in DataGridView. You can use DataGridView.Rows[index] to get the
DataGridViewRow reference.

Hope it helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 5 '06 #3
"randy1200" <ra*******@newsgroups.nospam> wrote in message
news:CF**********************************@microsof t.com...
Here's what I started with. It works great, but only selects the first
cell
in the row, rather than the entire row:

dataGridView1.CurrentCell = dataGridView1[0, index];

Here's what I came up with based on your suggestion:

DataGridViewRow row = dataGridView1.Rows[index];
row.Selected = true;

This really doesn't give me quite the same functionality, as it requres me
to keep track of the previously selected row, and set row.Selected =
false.
Is there no implementation of CurrentRow that give the same functionality
as
CurrentCell?


You could try setting SelectionMode to FullRowSelect, though this does mean
that you can't then select an individual cell.

Chris Jobson
Jun 5 '06 #4
I've just spent the last hour setting up Outlook Express. Unfortunately,
Outlook Express will only let me look at the last 300 messages, and
apparently, there's been more than 300 messages since I posted the original
question on 6/4/2006. The messages I can see in Outlook Express only go back
to 6/5/2006.

In Outlook Express, I've gone to Tools->Options and the Read tab. Under the
News line, I've increased the number of messages to get to 600. Still, it
only get's the first 300.

It kills me that I can't see the solution you've created. Is there some
other way to configure Outlook Express?
--
Randy
""Jeffrey Tan[MSFT]"" wrote:
Hi Randy,

Thanks for your feedback!

Based on your feedback, it seems that you want to achieve single row
selection in DataGridView, which does not require you to keep track of and
unselect the previous row.

I have created a sample project based your scenario, however, it works well
without any problem. In my sample project, there is no need to unselect the
previous select row. The DataGridView will unselect the previous row
automatically when we select the next row. I have attached my sample
project in this reply. You can get it with Outlook Express. Hope it helps.

Additionally, I recommended you to set DataGridView.MultiSelect property to
false. Does this resolve your problem?

If you still can not find out the root cause, please feel free to provide a
sample project to demonstrate your problem. Thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights

Jun 6 '06 #5
I figured out the Outlook Express problem. It turns out if you delete the
previously downloaded messages, it will then allow the download of the
higher number of messages.

I looked at your code. I appreciate the response - it does help.

Thanks again,
Randy

PS: If anyone else is interested, here's the lines that solve the problem:
this.dataGridView1.CurrentCell = dataGridView1[0, index];

this.dataGridView1.Rows[index].Selected = true;

""Jeffrey Tan[MSFT]"" <je***@online.microsoft.com> wrote in message
news:r9****************@TK2MSFTNGXA01.phx.gbl...
Hi Randy,

Thanks for your feedback!

Based on your feedback, it seems that you want to achieve single row
selection in DataGridView, which does not require you to keep track of and
unselect the previous row.

I have created a sample project based your scenario, however, it works
well
without any problem. In my sample project, there is no need to unselect
the
previous select row. The DataGridView will unselect the previous row
automatically when we select the next row. I have attached my sample
project in this reply. You can get it with Outlook Express. Hope it helps.

Additionally, I recommended you to set DataGridView.MultiSelect property
to
false. Does this resolve your problem?

If you still can not find out the root cause, please feel free to provide
a
sample project to demonstrate your problem. Thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.

Jun 6 '06 #6
"randy1200" <ra*******@newsgroups.nospam> wrote in message
news:C5**********************************@microsof t.com...
I've just spent the last hour setting up Outlook Express. Unfortunately,
Outlook Express will only let me look at the last 300 messages, and
apparently, there's been more than 300 messages since I posted the
original
question on 6/4/2006. The messages I can see in Outlook Express only go
back
to 6/5/2006.

In Outlook Express, I've gone to Tools->Options and the Read tab. Under
the
News line, I've increased the number of messages to get to 600. Still, it
only get's the first 300.

It kills me that I can't see the solution you've created. Is there some
other way to configure Outlook Express?


On the Tools menu there's an option "Get Next 300 Headers" (or maybe 600 in
your case) which enables you to look at older messages. The oldest messagesa
are can see are 28th April.

Chris Jobson
Jun 6 '06 #7
I am glad my reply makes sense to you. If you need further help, please
feel free to post. Thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 8 '06 #8

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

Similar topics

0
by: swartzbill2000 | last post by:
I have code that steps through the rows of a DataGridView, adding values to cells. How can I (in code) scroll the row I am working on into view, preferably at the bottom of the viewing window? Bill
0
by: mike | last post by:
I have a datagridview control and I am adding a new row in button click event. When the number of rows grow, the newly added row will not be visible but a scroll bar will be shown. I want the...
1
by: bob | last post by:
The help system says you can "get" (not set) the number of lines the mouse moves upon one "notch" of the wheel. The value for my system is 4. How do I force it to do only 1. Give me the EASY way,...
2
by: afamir | last post by:
Hi How can I scroll to selected row in datagridview when i select that rows with its index. thanks Amir Afshai
2
by: Irfan | last post by:
hi, In the datagridview, is it possible that when a datagridview loads it scrolls down automatically to show the last rows? I have a datagridview, in which the user has to modify one the columns...
0
by: hydroniumf | last post by:
Hi I have A datagridview in my form that has alot of rows then it has vertical scroll.(Its rows are added in run time) when scrollbar is scrolling by user , form hangs and doesn't work at all. how...
3
by: Richard Lewis Haggard | last post by:
I have an unbound DataGridView control that has some cells that may contain more multi-line text than can be completely displayed in the available screen space. When the height of its row to...
2
by: Michael Meckelein | last post by:
I get "Value of '3720' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum' exception if I remove rows in a dataGridView while scrolling from the top to the end of the grid...
6
by: ApexData | last post by:
I have created a Search Form that is basically a Popup ContinuousForm that consists of 15 fields(columns). When the user clicks on a record(row) the form closes and the selected record displays on...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.