473,387 Members | 1,621 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,387 software developers and data experts.

Adding new row to table in DataGridView

bob
After adding a new row (programmatically) to a table/view that is being
displayed in the DataGridView control, the new row appears in the
DataGridView grid. Now, how do I select that new row?

If the DataGridView is sorted by one of the columns/fields, the new row
could show up anywhere (based on the sort criteria).

Thanks.

Jun 27 '06 #1
2 2002
Hi Bob,

maybe this helps:
void Grid_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
_grid.FirstDisplayedCell =
_grid.Rows[e.RowIndex].Cells[0];
}

"bo*@datasync.com" wrote:
After adding a new row (programmatically) to a table/view that is being
displayed in the DataGridView control, the new row appears in the
DataGridView grid. Now, how do I select that new row?

If the DataGridView is sorted by one of the columns/fields, the new row
could show up anywhere (based on the sort criteria).

Thanks.

Jul 2 '06 #2
bob
Thanks for the idea. (What do you know -- there's a "RowsAdded" event
in the thing!). But no, it doesn't help, because "e.rowindex" returns 0
-- I guess the new row gets put first on the grid. But then, if the
grid is sorted (which it always is, in my app), the new row immediately
gets put somewhere else, so the "0" points to the new first row, which
is NOT the one just added. Good idea, though. It makes me want to try
harder to look through all the possible events when I have this kind of
problem. That's something I still need to do with this problem!

wansch wrote:
Hi Bob,

maybe this helps:
void Grid_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
_grid.FirstDisplayedCell =
_grid.Rows[e.RowIndex].Cells[0];
}

"bo*@datasync.com" wrote:
After adding a new row (programmatically) to a table/view that is being
displayed in the DataGridView control, the new row appears in the
DataGridView grid. Now, how do I select that new row?

If the DataGridView is sorted by one of the columns/fields, the new row
could show up anywhere (based on the sort criteria).

Thanks.
Jul 3 '06 #3

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

Similar topics

6
by: dbuchanan | last post by:
Hello, Is this a bug? Is there some kind of work around? I want to add default values for a few columns in my datagridview I found the "DefaultValuesNeeded" event for the datagridview I...
2
by: inpuarg | last post by:
Is it possible that - or is there any workarround for adding a new unbound row to a datagridview at bound mode ? Theese are not working. And i don 't want to add a row to dataset then rebind -...
4
by: Ian Semmel | last post by:
I have a DataGridView bound to a DataTable which is keyed on an Identity. Now I want users to be able to fill in the table just by enetering data and tab between fields and across row boundaries....
0
by: Christopher Lusardi | last post by:
Hello, I have a datagridview that is too wide for the form, so I'm trying to put scrollbars on the form and the datagridview table. But, when I run the application, look at the rightmost cells,...
1
by: kristian | last post by:
Hi all I have a simple form with not much more than a datagridview control, and want to show and edit the contents of a table in my mysql table. So far I have managed to set the db table as a...
0
by: Chris | last post by:
I have a DataGridView in a form that will display the information from various DataTables in my DataSet. The user is provided a list of tables and when they select a table name, the DataGridView...
1
by: max | last post by:
Dear Group, I'm just learning Windows Forms and C# (just in time for it to be replaced by MS What's Next) and have a question concerning displaying columnar data in a single datagridview. My...
1
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons:...
3
by: jehugaleahsa | last post by:
Hello: I am binding a DataGridView with a BindingList<T>, where T is a custom business object that implements INotifyPropertyChanged. When you bind a DataGridView to a DataTable, it has this...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...

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.