Which component can I use as a table in c#?

Asked

Viewed 131 times

0

[SOLVED] I got two information in the database, table products: ID and name. I need to show the user the ID and the name of all registered products.. The problem is that the listbox is just a list, it doesn’t work like a table. Does anyone know if there is any component I can put data side by side? in c#

  • Have you tried Gridview?

  • I tried to search on datagridview but only found about connecting database on it

  • I got, solved

  • @Sharisharu, if any of the answers solved your problem don’t forget to mark it as answered. If you solved it yourself, add the resolution as a response and mark it as answered, so it will help people who have the same question.

2 answers

0

For table is the Datagridview, and if you have a List of your object, just set the datasource of the dataGridView, example:

datagridview1.datasource = lista

Or else, if create manually, you need to create the columns first, and then make a foreach on your list and go adding row by row;

  • but this datagridview gives to put the elements that come in an array? Or is it necessarily important to link a database in it?

  • I already have the data in an array, just go to view, whatever it is

  • @Sharisharu on the property DataSource you can play objects with dice, no matter the source, may be for example a Arrayor a List, which may have been mounted in the code, read from a file xml,or from a database

  • Yes, you can. And for example if you have 2 columns in the datagridview, the Voce array will have position 0 and position 1, respectively when you do the datagridview.rows.add(array), it will assume in the columns the values.

  • Thanks guys, it worked out :D

0

Since you are searching data from the database, you can use an element called DataGridView.

inserir a descrição da imagem aqui

For more information on how to use it, follow some links:

  • But you can use datagridview without having to link it in the database, because I don’t connect to the database through visualstudio, I do it via code even using the odbc driver, and I’m already recovering this data with a ready search, now just visually dispose these data rs, I’ll take a look at

  • from what I’ve seen on your links, you’ve only been teaching him how to use it by connecting directly to the database, I want to pass an array to him

  • Thanks guys, I got it done

Browser other questions tagged

You are not signed in. Login or sign up in order to post.