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

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

19
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 1423

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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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.