display results in a table

shaunrigby

New member
Joined
Mar 31, 2007
Messages
4
Programming Experience
Beginner
Hi

How do i add data to a table layout panel programatically?
are there better ways to show search return data?

i have a form that allows a user to search a database of products and return the results in a table
 
Add "Data" ? Huh? A TableLayoutPanel is for arranging Controls (buttons, labels, other UI widgets) in a tabular fashion.

If you want to display data, use a DataGridView
 
i want to display the results as labels with 2 buttons,and if i was to use a datagrid wouldi need an adapter to display the information

sorry if im using the wrong terminology im more of a PHP programmer than a vb programmer
 
You don't need an adapter to use the DataGridView control (it is not the same as DataGrid control!).
The DataGridView control also support Button columns (that it sounds you want 2 of).
 
Here is my code:

VB.NET:
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dbConnection [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] MySqlConnection
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dbAdapter [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] MySqlDataAdapter
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dbCommand [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] MySqlCommand
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] DataSet [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataSet
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] DataGrid [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataGrid
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] drawingpoint [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Drawing.Point(12, 83)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] DGsize [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Drawing.Size(666, 596)
DataGrid.Location = drawingpoint
DataGrid.Size = DGsize
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dbText [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String
[/COLOR][/SIZE][SIZE=2]dbText = [/SIZE][SIZE=2][COLOR=#800000]"SELECT * FROM `Stock`"
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] categoryComboBox.Text <> [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]dbText += [/SIZE][SIZE=2][COLOR=#800000]" WHERE `category_tier2` = '"[/COLOR][/SIZE][SIZE=2] & categoryComboBox.Text & [/SIZE][SIZE=2][COLOR=#800000]"'"
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] categoryComboBox.Text <> [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]And[/COLOR][/SIZE][SIZE=2] searchtermTextBox.Text <> [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]dbText += [/SIZE][SIZE=2][COLOR=#800000]" AND"
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] searchtermTextBox.Text <> [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]dbText += [/SIZE][SIZE=2][COLOR=#800000]" WHERE `short_description` LIKE '%"[/COLOR][/SIZE][SIZE=2] & searchtermTextBox.Text & [/SIZE][SIZE=2][COLOR=#800000]"%'"
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2]dbText += [/SIZE][SIZE=2][COLOR=#800000]" LIMIT 5"
[/COLOR][/SIZE][SIZE=2]dbConnection.ConnectionString = [/SIZE][SIZE=2][COLOR=#800000]"server=mysql.xsession.net; user id=sbroot; password=N1311gsc78; database=spacebar"
[/COLOR][/SIZE][SIZE=2]dbCommand.Connection = dbConnection
dbCommand.CommandText = dbText
dbAdapter.SelectCommand = dbCommand
[/SIZE][SIZE=2][COLOR=#008000]'dbConnection.Open()
[/COLOR][/SIZE][SIZE=2]dbAdapter.Fill(DataSet, [/SIZE][SIZE=2][COLOR=#800000]"Stock"[/COLOR][/SIZE][SIZE=2])
DataGrid.DataSource = DataSet.DefaultViewManager
[/SIZE]

See if you guys can fathom it out, it is doing nothing
 
Back
Top