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

DataGridView.CurrentCell (Set)

Someone has an example, C#, about how to set the cell(int row, int col) as
the current cell for a DataGridView. The example, in the help file, about
DataGrid.CurrentCell Property (Set)

myGrid.CurrentCell = new DataGridCell(1,1);
does not work, fro a DataGridView, since we cannot create a DataGridView
Cell while specifying only its row and column.
Vanderghast, Access MVP
Feb 14 '08 #1
4 20110
Sorry for the bandwidth, just found that I just have to point to that said
cell, after all... doh. No need to 'create' one, as the example from
DataGrid leads us to think. The following works:
dataGridView1.CurrentCell = dataGridView1.Rows[iRow].Cells[iCol];


Vanderghast, Access MVP

"Michel Walsh" <va*************************@nospam.comwrote in message
news:0D**********************************@microsof t.com...
Someone has an example, C#, about how to set the cell(int row, int col)
as the current cell for a DataGridView. The example, in the help file,
about DataGrid.CurrentCell Property (Set)

myGrid.CurrentCell = new DataGridCell(1,1);
does not work, fro a DataGridView, since we cannot create a DataGridView
Cell while specifying only its row and column.
Vanderghast, Access MVP

Feb 14 '08 #2
Michael,

There are more succinct ways of doing this:

dataGridView1.CurrentCellAddress = new Point(1, 1);

Or, if you wish:

dataGridView1.CurrentCell = dataGridView1[1, 1];

Both should have the same effect, although the top example will help
prevent unsharing of rows, which is good when you are using the grid in
virtual mode.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Michel Walsh" <va*************************@nospam.comwrote in message
news:7F**********************************@microsof t.com...
Sorry for the bandwidth, just found that I just have to point to that said
cell, after all... doh. No need to 'create' one, as the example from
DataGrid leads us to think. The following works:
dataGridView1.CurrentCell = dataGridView1.Rows[iRow].Cells[iCol];


Vanderghast, Access MVP

"Michel Walsh" <va*************************@nospam.comwrote in message
news:0D**********************************@microsof t.com...
>Someone has an example, C#, about how to set the cell(int row, int col)
as the current cell for a DataGridView. The example, in the help file,
about DataGrid.CurrentCell Property (Set)

myGrid.CurrentCell = new DataGridCell(1,1);
does not work, fro a DataGridView, since we cannot create a DataGridView
Cell while specifying only its row and column.
Vanderghast, Access MVP

Feb 15 '08 #3
If I can ask you one more question.
While

dataGridView1.CurrentCell = dataGridView1[1, 1];

is fine for me, if I consider dataGridView[1,1] is a reference (a pointer)
to an existing cell, and then CurrentCell property just 'set the focus' on
that 'object reference' it got as its 'value', I fail to see how:
dataGridView1.CurrentCellAddress = new Point(1, 1);
could even work, since

new Point(1, 1)

is also a reference, but totally unrelated to any cell-references
(cell-pointers) owned by the dataGridView object. With this, in
consideration, can you explain the inner-working of
dataGridView1.CurrentCellAddress = new Point(1, 1);


Thanks for your time
Vanderghast, Access MVP

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:C3**********************************@microsof t.com...
Michael,

There are more succinct ways of doing this:

dataGridView1.CurrentCellAddress = new Point(1, 1);

Or, if you wish:

dataGridView1.CurrentCell = dataGridView1[1, 1];

Both should have the same effect, although the top example will help
prevent unsharing of rows, which is good when you are using the grid in
virtual mode.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

Feb 15 '08 #4
Michel,

As you and Andrus pointed out, you the CurrentCellAddress property is
read-only, so you can't set it.

So only the first example I gave is valid.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Michel Walsh" <vanderghast@VirusAreFunnierThanSpamwrote in message
news:uS**************@TK2MSFTNGP04.phx.gbl...
If I can ask you one more question.
While

dataGridView1.CurrentCell = dataGridView1[1, 1];

is fine for me, if I consider dataGridView[1,1] is a reference (a pointer)
to an existing cell, and then CurrentCell property just 'set the focus' on
that 'object reference' it got as its 'value', I fail to see how:
dataGridView1.CurrentCellAddress = new Point(1, 1);
could even work, since

new Point(1, 1)

is also a reference, but totally unrelated to any cell-references
(cell-pointers) owned by the dataGridView object. With this, in
consideration, can you explain the inner-working of
dataGridView1.CurrentCellAddress = new Point(1, 1);


Thanks for your time
Vanderghast, Access MVP

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote
in message news:C3**********************************@microsof t.com...
>Michael,

There are more succinct ways of doing this:

dataGridView1.CurrentCellAddress = new Point(1, 1);

Or, if you wish:

dataGridView1.CurrentCell = dataGridView1[1, 1];

Both should have the same effect, although the top example will help
prevent unsharing of rows, which is good when you are using the grid in
virtual mode.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

Feb 16 '08 #5

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

Similar topics

2
by: michael Schindler | last post by:
How i can set in a datagrid in c# widows forms in a specifig cell example Row 3 column 4 a specifig data for example "Michael"? I want after the user give in a cell in my datagrid additionally...
4
by: steve | last post by:
Hi All I have a datagridview bound to a datatable Due to the use of touch screens I need to be able to scroll the grid in code in response to a button click i.e each button touch (click) will...
2
by: DBC User | last post by:
I would like to know how to set a focus to a datarow? (using datarow.selected=true, select the row but does not show the row on the screen visible if it is below/above the grid display area).
7
by: Ryan | last post by:
I have a DataGridView which displays numeric (Int32) data from an underlying database. I want the numbers to be displayed in numeric format "#,###" (with commas). I want to also limit the user so...
1
by: Andy | last post by:
Hi I have an app with an datagrid that I will replace with a datagridview controll. In the old datagrid I could use datagrid.currentrowIndex to get the index value for the current datarow,...
1
by: =?Utf-8?B?Z3RlYQ==?= | last post by:
Hi, I don’t want any rows in the DataGridView selected initially on the form programmed in C#. How can I do it? I have tried to set DataGridView.CurrentCell = null, but it doesn’t work for...
2
by: Huy Nguyen | last post by:
Hello, How can i force the cell to accept the input for now and flag it as error for user to correct it later. For Example: case 1. I have a column that is NOT bound to database table, then I...
3
by: Andrus | last post by:
I have DataGridView in virtual mode containing 3500 rows. In code below, assigning to RowCount value to 3500 takes 8 seconds. CPU usage goes high at this time. Stepping by F11 into user code shows...
4
Luckie
by: Luckie | last post by:
Hi All experts there, I am developing a software using datagridview (vb6 feels better) and i am using virtualMode. it shows the focus blue box but it is not possible to fill data to the first...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
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,...
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.