adding rows dynamically to an unbound DatagridView control in VB.net

Posted on 2008-02-11
Medium Priority
Last Modified: 2013-11-26
This is my problem. I am adding ROWS dynamically to a datagridview using this statement:

Dim vRow() As String = {Trim(datefiled), Trim(ctyID), Trim(Type), Trim(Name), Trim(status)}

where grdconsole is an unbound datagrid. And I am adding a ROw to the grid after a record is processed. What is happening is that the ROW is getting added to the END. What should I do to add the row to the begining so the latest ones appear on top?

Please let me know.
Question by:VBSolutionSeeker
  • 3
  • 2
LVL 22

Accepted Solution

JimBrandley earned 1500 total points
ID: 20867454
You can use this:
grdConsole.Rows.Insert(rowIndex, values)

rowIndex is the position where you want the row inserted.


Author Comment

ID: 20869375
I have no idea as to how many rows would be there in the grid. it is infinite. Could you please give me sample code as to how i would go about adding the rows so that the later ones appear on top? Even with the index, it is going to add it to the bottom, right?

LVL 22

Expert Comment

ID: 20869588
I think in VB, the first index = 1. If you keep inserting at 1, each new one will be at the top of the list.


Author Comment

ID: 21032414
could you please give me some sample code. i tried doing this in vain. thanks in advance


Author Comment

ID: 21154560
i finally got around doing this. thanks all.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article describes and provides a custom-made tool I wrote to give businesses a means of identifying commercial music content, without having to expend too much effort. Business recordings are easily identified from possibly illegal music files …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
If you are looking for an automated tool which can generate reports for Outlook emails and other items from PST file, then you can go for Kernel PST Reporter tool. The reports which are created by this tool are helpful to analyze and understand PST …

587 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