473,473 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How can I rearrange the rows of a DataGridView in the code?

19 New Member
I have a DataGridView of WinForms, and I want to be able to rearrange the rows using a ListBox located elsewhere. So when I remove an entry from the ListBox, the following line is run:
Expand|Select|Wrap|Line Numbers
  1. dataGridView1.Rows.RemoveAt(e.Index);
And when an element is added to the ListBox, the following code is executed:
Expand|Select|Wrap|Line Numbers
  1. dataGridView1.Rows.Insert(e.Index, row);
Except that an exception (InvalidOperationException) is thrown since the row is in the DataGridView. When I tried to wrap this line with a try block with an empty catch, the row was clearly not there. Any ideas on how to solve this?
Apr 21 '15 #1
0 1425

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

Similar topics

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...
1
by: jjmurali | last post by:
hi guys i have one problem with datagridview.. i m displaying data in datagridview in c# application. i added one checkbox column to datagridview ..as well as i have one button(Select All),...
0
by: teo | last post by:
Hello. I have a DataGridView with a lot of rows. I created a sort of "Goto" . I used the CurrentCell property. The DataGridView scrolls down and the new cell is now visible and it is blue...
2
OuTCasT
by: OuTCasT | last post by:
Please can someone tell me how to add the totals of a single coloumn from a datagridview ? Private Sub UpdateLabelText() Dim SelectedCellTotal As Integer = 0 Dim...
3
by: Christian | last post by:
Hi, i create aprogram that load a table from Access DB. i want color rows with different color but when i run the program and i load the datagridview the first time, the rows are white! only when...
4
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I use unbound DataGridView controls in my form (simply because I have to manually message my data before populating the DataGridView with it). Say I clear all the info from the DataGridView: ...
6
by: akshaycjoshi | last post by:
I have one datagridview which i fill using the connected verion of ADO.NET. When the user presses the search button a seperate thread is created and in that thead i connect to the database and fill...
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...
1
by: Zack00000 | last post by:
Hi, Is there a way to optimize the DataGridView in terms of drawing speed? The application that I'm building will need to use multiple datagridview controls which will get updated around every...
0
by: priyamtheone | last post by:
I'm trying to make a datagridview column to act like a datetimepicker column (C#.Net 2005). These are the behaviours that the dgv should have: 1) Initially all the cells of the dtp column should be...
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
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,...
1
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...
1
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...
0
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...
0
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 ...
0
muto222
php
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.