473,734 Members | 2,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding new row to table in DataGridView

bob
After adding a new row (programmatical ly) 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 2033
Hi Bob,

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

"bo*@datasync.c om" wrote:
After adding a new row (programmatical ly) 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, DataGridViewRow sAddedEventArgs e)
{
_grid.FirstDisp layedCell =
_grid.Rows[e.RowIndex].Cells[0];
}

"bo*@datasync.c om" wrote:
After adding a new row (programmatical ly) 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
6413
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 gave it a try using the example given in
2
8350
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 - cause i want to add this row to a specific location. and it does not match to sort order. Regards. and thanks. base.Rows.InsertCopy(base.CurrentRow.Index, 1); base.Rows.Insert(base.CurrentRow.Index, 1);
4
1815
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. What I am having trouble with is deciding when to update the table and I keep on getting exceptions (like DbNull). Do you have to do an update at the end of each row ?
0
1178
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, and click on one of the rightmost cells the form scrolls to the leftmost end of the datagridview. I tried various permutations of the form's autoscroll, the datagridview's scrollbars, and the datagridview's selection mode without success. What do...
1
8290
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 datasource for the datagridview, and display the contents. Code bit: public partial class FormEditDbTable : Form
0
1172
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 displays the appropriate DataTable. When a user changes some of the settings in my program, I sometimes have to recreate some of the DataTables, however, the DataGridView will still somehow display the original DataTable even if the DataGridView...
1
1371
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 data is stored as a collection of column objects , each of which contains an array of values as well as datatype info. I want to assemble an ordered group of these columns into a data table and use a datagridview to manipulate it. Basically,...
1
3378
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: 1) export to excel button exports the visible columns from the datagridview to excel (this works fine)
3
9688
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 cool little feature - it will not call DataTable.Rows.Add until after you leave the DataGridView row. This is cool because it lets your user edit the record as much as needed to get it into a valid state before actually adding it to the DataTable.
0
9449
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9182
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.