473,396 Members | 2,109 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.

To delete a row in access table from datagridView using ContextMenuStrip

hi..
how to delete the selected row in datagridview using ContextMenuStrip.When i right-click and press "delete" the seleted row in the dataGridView has to be deleted and as well in my access table.I am new to C#.net

my coding is this:
Expand|Select|Wrap|Line Numbers
  1.             int curRow = 0;
  2.             curRow = this.dataGridView1.CurrentRow.Index;
  3.             this.dataGridView1.Rows.RemoveAt(curRow);
  4.  
but it is deleting only in datagridView and it is not getting updated in my access table.plz help me with the code,where i should write my query to delete based on the selected row .plz help me
Jan 24 '09 #1
2 7411
skepar
1
Hi there !
I got the same problem check out this:
# int curRow = 0;
# curRow = this.dataGridView1.CurrentRow.Index;
# this.dataGridView1.Rows.RemoveAt(curRow);
->this.tableAdapterManager.UpdateAll(this.YourDataS et);<-
Mar 18 '09 #2
private void contextMenuStrip1_Click(object sender, EventArgs e)
{
if (!this.dataGridView1.Rows[this.rowIndex].IsNewRow)
{
this.dataGridView1.Rows.RemoveAt(this.rowIndex);
}
}

Full source...Delete from datagridview on right click

watson
Jun 3 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Opettaja | last post by:
Okay so I created a ContextMenuStrip, this menu will have options for editing or deleting rows of the datagridview. The problem is I dont know how to set the ContextMenuStrip to the individual rows...
0
by: Bob | last post by:
1- Inability to easily reset datagridview combobox selection to null Solution - add a contextmenustrip to the column in which you have the combobox on the datagridview. show to user, something like...
1
by: Dave | last post by:
I have a table with 3 fields of which the primary key is a autonumber. I have created my dataadapter, dataset and datagridview using a wizard. However, in the datagrid, the update and delete...
5
by: Brett Romero | last post by:
I have a simple test app with one form, one datagridview, and a contextmenustrip. I've assigned the menustrip to the datagridview and given the grid one column. There isn't any data in the grid. ...
3
by: Daniel Manes | last post by:
I need a strategy to debug this situation... I can't put all the code involved, but here are some of the critical lines with comments: ------------------------- Private _parentDataCell As...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
On a form - I have a datagridview which is docked to the entire form. The datagridview allows users to Delete and/or Add Rows. On the Form_Load event I Fill the datagridview source table with a...
0
by: quangnd0003 | last post by:
I have a event to Cancel Delete of user : private void dataGridViewKV_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { string maKV =...
1
by: Bob | last post by:
Hello, Using VB 2005.net. I have a bound datagridview and a delete button control (or when the user pressed the 'Delete' key) I can successfully delete the selected record from the table and...
3
by: =?Utf-8?B?S2F5xLFoYW4=?= | last post by:
In my project,i added datagridview to my form , i transfered my table to datagridview and added multiple rows and when i called dataadapther.update ,,result is ok. But when i tried it for the...
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: 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
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...
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
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
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.