Grid without using database

Hello, is it possible to have a grid on the screen (like a datagrid) without connecting the grid to a data control?


Who is Participating?
Jacques Bourgeois (James Burger)Connect With a Mentor PresidentCommented:
Once you will have crossed the wall that we all meet when moving from VB6 to VB.NET, you won't want to go back. It's a big step, but really worth it.


What's the use of the grid?

Is this only to let the user select something and you will get the number to do something else afterward?

Does the user needs to see the number?

Your could have a ComboBox that displays the text and hides the number. You would then be able to retrieve the number for the selected text in only one line of code.

If so, tell me and I will show you how to do it with a ComboBox.

Otherwise we will go with the grid. For this one, you will need to have a version of Visual Studio that has the DataGridView control, not the DataGrid that was provided with the first versions of VS.
Jacques Bourgeois (James Burger)PresidentCommented:
You probably have roots in VB6 :-) There is no DataControl in .NET. There is a BindingNavigator that plays a little of the same role, but is not exactly the same thing.

To answer your question: yes.

A datagrid can work with any array or collection in the .NET framework.

It can also be fed cell by cell. This is not hard to do if you want only to display invormation, but it can become more involved if the user need to edit the code and you need to keep the result changes).

What type of data do you want to put in the grid?
pvg1975Author Commented:
Hi James!

Yes, I did VB6 A LOT!!! and I just moved to .NET

I need to fill a grid with numbers and text only, that's all.
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

pvg1975Author Commented:
Hi James! Yes its hard for me... to late to move, the company I work for had a huge application in VB6 and I got stucked on it... anyway, time to move :)

The grid is to enter numeric values coming from some textboxes.

I tried this:

MyGrid.Item(0, MyGrid.RowCount - 1).Value = N1.Text
MyGrid.Item(1, MyGrid.RowCount - 1).Value = N5.Text
MyGrid.Item(2, MyGrid.RowCount - 1).Value = N2.Text

with the intention of adding a row and possitioning the values on that last row, but what it does is to delete all previous entered rows and place the text on the last row.
pvg1975Author Commented:
Oh, Im using a datagridview not linked to any database.
pvg1975Author Commented:
I made it work like this:

                Dim row = New String() {"4", "25", "4000"}

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.

All Courses

From novice to tech pro — start learning today.