473,698 Members | 2,426 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 2029
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
6411
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
8349
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
1813
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
1174
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
1170
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
3372
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
9683
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
8678
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8899
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
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...
1
6525
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
5861
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
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.