We help IT Professionals succeed at work.

Better way to bind hundreds of text boxes to datatable

I was asked to create a read only user interface to an old database where I'll need to display the data across multiple tab pages and a couple of hundred text boxes.  Ordinarily it's not a big deal to use the binding source and connect the boxes to the tables but I lost count around 200.   I poked around a little bit with creating all the boxes at run time looping through the columns to create them (and bind them) but I didn't care for the layout and it became more of a hassle.  Now I have this project with even more boxes to bind to datatables and I'm looking at dozens of hours.  Ok, maybe a day, but I still wonder if there's a more efficient way?

I'm using VB.net and Visual Studio 2017

Thanks for any thoughts
Watch Question

Chinmay PatelChief Technology Ninja
Distinguished Expert 2019

Hi zipnotic,

Can you clarify if this is a WinForm or WebForm/MVC project?



My bad,  this is a winforms project.  Stacking the boxes vertically makes too scrolling and tabularizing is just ugly.  I also have to deal with the cryptic field names.  If I do something dynamic I might build a cross reference (lookup?) table so field inc_per_pk translates to human readable label on the field.  Doesn't seem like it save much work though for a static FB viewer.
I decided to go super lazy and created a datagrid and looped through each field and it's value turning the single row vertical so the field/ column name displays as column 1 in the Datagridview and the value displays as Column 2.  It scrolls past the bottom of the screen but with some formatting of the grid it doesn't look half bad and took 4 lines of code per table rather than binding hundreds of individual boxes to a datatable.