yanivpinhas

I want to make in VB2005 Express edition a sample

table(like you can build in word) and all I can find is talking about SQL database or others database.

So if you can send me a sample code of how to make sample table

and how can I insert data for each cell.

and how can I merger two or tree cells to be one cell.

I be glad...

Best Regards,

Yaniv Pinhas



Re: Visual Basic Express Edition How to do a sample table?

ssimon

To create a Table :

Design Mode: Click on the Layout Menu and the Insert Menu

Source Mode: You can code this by the following:

<table>
<tr>
<td colspan="2">Two Cells Merged</td>
<td style="width: 100px">1</td>
</tr>
<tr>
<td style="width: 100px">2</td>
<td style="width: 100px"></td>
<td style="width: 100px">3</td>
</tr>
</table>

Line One: <table> Tells HTML that you are going to Create A Table
Line Two: <tr> Tells HTML that you are starting a New Row in your Table - everything between Line 2 (<table>) and line 5(</tr>) will be included within the first row
Line Three: <td colspan="2">Two Cells Merged</td> The td tells HTML that you are going to create Table Data, colspan="2" tells it that it is going to span the cell across 2 cells (or merge the first two cells as in Excel or Word). Next your text that you want to show in the cell is typed out. The </td> states that this is closing out the Table Data for this cell.
Line Four: Same as Line Three except you are only using one cell this time
Line Five: Tells HTML that you are closing out the Table Row
**NOTE : The first table row contains two rows of data while the next table row contains three...Why To have a uniform table you should have data or a blank cell (see line 8) to keep everything lined up and in perspective.
Line Six: <tr> We are going to add a new row
Line Seven: Same as Line Four Description
Line Eight: Same as Line Four Description except this time we have no data in the cell
Line Nine: Same as Line Four Description
Line Ten: We are closing out our Table Row
Line Eleven: We close out our Table with </table> stating that we have finished creating our table.

Hope this helps out





Re: Visual Basic Express Edition How to do a sample table?

yanivpinhas

I didn't understand how can I use HTML code in VB2005 exp

I mean to first line that you wrote:

Design Mode: Click on the Layout Menu and the Insert Menu

I didn't have Layout so I click on tools=>customize => then add Layout

he add some buttons but thay in gray color(not working) and I didn't find insert menu

So I guess I didn't understand you well...

Best Regards,

Yaniv Pinhas





Re: Visual Basic Express Edition How to do a sample table?

yanivpinhas

Why is it so difficult to make a sample table

still didn't find how to do this...........





Re: Visual Basic Express Edition How to do a sample table?

yanivpinhas

I search information about using HTML code

but nothing works...

What I'm missing here...





Re: Visual Basic Express Edition How to do a sample table?

yanivpinhas

If someone think that it can't be done I be glad to know that

because I'm spending a lot of time to understand this...





Re: Visual Basic Express Edition How to do a sample table?

Bruno Yu - MSFT

yanivpinhas,

According to your demand, I recommend you to use DataGridView on the form to create a table that generates the data from database.

The DataGridView control provides a customizable table for displaying data. The DataGridView class allows customization of cells, rows, columns, and borders through the use of properties such as DefaultCellStyle, ColumnHeadersDefaultCellStyle, CellBorderStyle, and GridColor.

You can use a DataGridView control to display data with or without an underlying data source. Without specifying a data source, you can create columns and rows that contain data and add them directly to the DataGridView. Alternatively, you can set the DataSource and DataMember properties to bind the DataGridView to a data source and automatically populate it with data.

Please take a look at the DataGridView class instruction in MSDN, there is a code example on how to initialize an unbound DataGridView control in the following link:

http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridview.aspx






Re: Visual Basic Express Edition How to do a sample table?

yanivpinhas

Thank you for your answer..

But how can I merge two or three cells

Best Regards,

Yaniv Pinhas





Re: Visual Basic Express Edition How to do a sample table?

Bruno Yu - MSFT

yanivpinhas,

Where would you like to merge cells In DataGridView or in Office application In VBA or VSTO application, there is a method called Merge method that merges the specified table cell with another cell. The result is a single table cell. You can get the method here in the link: http://msdn2.microsoft.com/en-us/library/aa211275(office.11).aspx

I'm afraid it is hard to merge cells in DataGridView control. Could you please make you question specific next time on merge cell

You can also read the following article that can help you to understand the merge in Office application:

How To Automate Microsoft Word to Perform a Mail Merge from Visual Basic .NET

http://support.microsoft.com/kb/301656/






Re: Visual Basic Express Edition How to do a sample table?

yanivpinhas

Thank you for your answer.

I just wanted to show in my VB program a beautiful table like everyone can do in Excel, Word or webpage(Html)

and I know how to do this in Excel,Word or Html but in VB2005 Express edition I didn't succeed.

So I tried with DataGridView to do this (I know how to do a table with data) but I wanted to merge two cells in this table

and I look on your link that you attached and this is the example that show there:

Sub MergeCell()
With ActiveDocument.Pages(1).Shapes(2).Table
.Rows(1).Cells(1).Merge MergeTo:=.Rows(2).Cells(1)
End With
End Sub

So I copy paste this to my program and I get error that:

name ' ActiveDocument ' is not declared

If you can I help me I be glad...

If there any other way to do this or any example that show how to do this

it can be great because it is very basic thing that everyone need to know...

Best Regards,

Yaniv Pinhas





Re: Visual Basic Express Edition How to do a sample table?

yanivpinhas

UP!



Re: Visual Basic Express Edition How to do a sample table?

yanivpinhas

UP!UP!



Re: Visual Basic Express Edition How to do a sample table?

SJWhiteley

It isn't clear at all whatyou are trying to achieve with your program: you you want to replicate the functionality of Excel There is no concept of 'cell' within VB: that's why you were directed to use a datagridview which has cells. It seems you want to do more with it than simply display data in a grid: what you want - merging cells - cannot be done natively. You would have to use a bit of imagination on the datagridview to achieve what you want: it's a complex control.

However, if you want to simply display the data, then how about using a webbrowser control, and displaying the results in an html table

VB is not a replacement for excel, word or a web browser: because it is easy in those applications does not mean it can be easily done in VB (or any language), and perhaps is the reason for not getting the reply you hoped for.