Kingy_Owl

This may sound a very simple question, but how do I create a table in VB Express 2005 I'm trying to create a table as you could have on a webpage, with different coloured text and background colours in certain cells.

I would prefer not to link to an external data source, and rather have the data entered in the table in the design view so when a user opens the form the table is there filled in with all the data.

The closest thing I've found is Data Grid view, but I don't know how to add the cell contents under properties or change any colours of random cells.

If the only way to do this is to link to an external database code could someone explain how to do this please

Thanks.

Regards, Andy



Re: Visual Basic Express Edition Creating a web style table in VB 2005

Derek Smyth

Hey man,

Yeah the DataGridView sounds like the control to use. The CellFormatting event can be used to change the colour of the cells being displayed, it's bit tricky though but not impossible. Behind the scenes you can use a DataTable object (like an database table, columns and rows) and bind it to the DataGridView. The user could add data to the DataTable through the DataGridView and the CellFormatting event would colour it in for you.

The DataTable would be a good object to use, the user could fill it in through a form yet if you did need to go to the database then you could also. This is the approach I would take.

The other option thought, if your looking purely for a read only table display could be to use the web browser control and just take your data and format it into an HTML table and display it through the web browser.






Re: Visual Basic Express Edition Creating a web style table in VB 2005

Kingy_Owl

Hi, I decided to give the web browser method a go because I only want a read only table and it would be easier to design and edit in HTML.

The only thing I'm stuck with now is does the web browser have to point to a specified URL on the web, or can it point to a htm file saved in the application directory

For example, I have a file named start.htm saved in my application directory, I have used the following code to try and point the browser to it:

WebBrowser.Url = My.Application.Info.DirectoryPath & "\start.htm"

This code generates the following error however:

Error 1 Value of type 'String' cannot be converted to 'System.Uri'.

Does anyone know a way to make the web browser control point to htm files stored locally

Thanks, Andy.





Re: Visual Basic Express Edition Creating a web style table in VB 2005

Derek Smyth

Hi mate,

You can write the HTML directly into the browser like this...


Me.WebBrowser.Document.Clear()
Me.WebBrowser.Document.Write("<html>...")
Me.WebBrowser.Document.Close()

You can also do this...

Me.webBrowser.DocumentText = "<html>..."

If you want to point to local file yous use the file:// protocol

WebBrowser.Url = New Uri("file://C:\page.html")






Re: Visual Basic Express Edition Creating a web style table in VB 2005

Omar Abid

Add an SQL or Access Data base first then make a relation between the Data Grid View and the Data Base and select the Table that you want




Re: Visual Basic Express Edition Creating a web style table in VB 2005

Kingy_Owl

Hi, thanks for your help, the ("file://...) code seems to be what I need. Is it possible to change it to point to wherever the application is installed as I mentioned in my previous post instead of writing the whole path which could be different on different pcs

I could code the html into the browser as you also suggested, but there are a number of pages and alot of code could slow down the app.

Thanks again.





Re: Visual Basic Express Edition Creating a web style table in VB 2005

Omar Abid

Hi Derek,

is me.webbrowser.document.clear() ... like Echo '' on PHP

thx