r/visualbasic • • Feb 12 '16

[HELP][Visual Studio Community 2015] Is there a way to make an editable excel-like table on a VB form?

I'm trying to make a program that deals with arrays of numbers and allows users to input data in a table which can then be read and altered by the program. I'd like this table to be of variable length definable by the program, but with a fixed number of columns, and have a scrollbar which only scrolls the table. This is a mockup of what I'm looking to do. I don't need it to work like an excel, that is, it doesn't need to be able to solve formulas or be formattable or any of that, I just want the data entry to be just like excel. I have been searching everywhere trying to find if this is possible, or if there is another programming language that could better handle this. Thanks!

5 Upvotes

4 comments sorted by

5

u/hdsrob Feb 12 '16

I think the DataGridView would do what you want.

It's a grid control that's designed to deal with data in rows and columns (generally in a fixed column width, and a variable number of rows).

2

u/audiyon Feb 13 '16

Thankyou, this is exactly what I was looking for. It does raise a second question though, which is, is there an easy way to copy and paste cells from an Excel into the DataGridView or any known codes which do it well?

3

u/hdsrob Feb 13 '16

You'll have to code the paste function yourself by parsing the content of the clipboard.

Here's a detailed article with info on how to do it:

http://www.codeproject.com/Articles/36850/DataGridView-Copy-and-Paste

It's in C#, but should be pretty straight forward. If you aren't comfortable reading C# yet, you can run the code through a converter: http://converter.telerik.com/

2

u/darkspy13 Feb 13 '16

You could export the excel doc as a .CSV file and then read the CSV in using VB.

a quick google search on "how to read a CSV file using VB.Net" should get you rolling. I don't believe it is very hard, if you get stuck just shoot me a PM or reply to this comment and I can help.

Good luck however you solve this.