[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

VB.Net Datagridview adding items

Posted on 2011-03-11
5
Medium Priority
?
677 Views
Last Modified: 2012-05-11
I have a datagridview that is constantly having data added to it (read through a serial port), and it has 5 columns.  My manager wants the most recent items to be added to the top, not the bottom which is the default way, so that anyone observing can actually see that data is coming in.

The way I am doing this right now is to do a sort on one particular column (date), so the latest shows at the top.

The problem is that when the datagridview has a few thousand rows, and I have to keep doing this sorting, it takes the CPU usage to 100% constantly.  

My question is this:  is there a way to have it so that when you datagridview.rows.add, for the data to automatically be added to the top of the datagrid, so I don't have to keep doing a sort?

Thanks.
0
Comment
Question by:LD147
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:4runnerfun
ID: 35109712
I don't have the answer for adding data to the top, but if the idea is to keep the latest entry in view, you can have the datagridview auto focus on the last line.

Which looks like it's been addressed here before.
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_21625418.html

Quote-
I hade add  DataGrid1.CurrentRowIndex = CType(DataGrid1.DataSource, DataSet).Tables(0).Rows.Count() AFTER a functions format the grid(cell size,align etc) then it worked finde.


Also addressed here:
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22121460.html


======= hmm more...

adding at top... possibly
http://stackoverflow.com/questions/5104563/datagridview-add-new-entries-at-the-top

http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22606378.html
0
 
LVL 17

Accepted Solution

by:
nepaluz earned 2000 total points
ID: 35109901
if you are manually adding the data to the datagridview, use the insert method to insert at 0 (line zero)
0
 
LVL 1

Author Comment

by:LD147
ID: 35110185
Nepaluz:  that works perfectly and is exactly what I need!  Thank you!

4runnerfun: Using CurrentRowIndex also is ok, as it sets the focus to the bottom of the grid.  I would have used this if Nepaluz hadn't given me his information.  Thank you for the suggestion.
0
 
LVL 3

Expert Comment

by:4runnerfun
ID: 35110229
Np, the last link I listed was about the insert method.. ;) but it's all good. Glad you got what you needed.
0
 
LVL 1

Author Comment

by:LD147
ID: 35110263
Ahhh....I checked the first two links of yours, and I was going to accept the CurrentRowIndex method, then I saw Nepaluz's message....lol.  Thanks again! :)
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question