DataGrid - 2 table comparisons

D

Dave

Are there any add-on products or samples available that can do the following
in an vb.net datagrid

I want to compare 2 rows in a datagrid - one row from one database and
another row for another database.

So all the even rows would be from database one.
All the odd rows would be from database two.

Row one and two will have different formats and colors.

I want to edit either row.

Thanks

Dave
 
C

Cor Ligthert

Dave,

The datagrid is a representation on screen for the user of data in a
datasource, so I don't understand what you want to do.

There are thousands of methods to compare the data in the underlaying
datasource.

What is it you want to do?

Cor
 
D

Dave

I want to see 2 tables in the same datagrid -

the odd rows will show table 1
the even row will show table 2

i won't to be able to format the even rows differenently then the odd rows.
Formatting including lines and collors.

The even rows will show data only if is differently then odd rows.

thanks

Dave
 
K

Kevin Yu [MSFT]

Hi Dave,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that this issue involves 2 problems. One is
how to merge two tables' data into one, and the other is how to make the
even and odd rows display with the different formats. If there is any
misunderstanding, please feel free to let me know.

To merge data, there is no direct method to achieve this. We have to create
a new data table, and copy rows from the two tables one by one.

We can also use DataGrid's AlternatingBackColor and AlternatingItemStyle
property to change the format for odd rows. Here is a sample code snippet.

private void CopyDefaultTableStyle(DataGrid datagrid,
DataGridTableStyle ts)
{
ts.AllowSorting = datagrid.AllowSorting;
ts.AlternatingBackColor = datagrid.AlternatingBackColor;
ts.BackColor = datagrid.BackColor;
ts.ColumnHeadersVisible = datagrid.ColumnHeadersVisible;
ts.ForeColor = datagrid.ForeColor;
ts.GridLineColor = datagrid.GridLineColor;
ts.GridLineStyle = datagrid.GridLineStyle;
ts.HeaderBackColor = datagrid.HeaderBackColor;
ts.HeaderFont = datagrid.HeaderFont;
ts.HeaderForeColor = datagrid.HeaderForeColor;
ts.LinkColor = datagrid.LinkColor;
ts.PreferredColumnWidth = datagrid.PreferredColumnWidth;
ts.PreferredRowHeight = datagrid.PreferredRowHeight;
ts.ReadOnly = datagrid.ReadOnly;
ts.RowHeadersVisible = datagrid.RowHeadersVisible;
ts.RowHeaderWidth = datagrid.RowHeaderWidth;
ts.SelectionBackColor = datagrid.SelectionBackColor;
ts.SelectionForeColor = datagrid.SelectionForeColor;
}

For more information, please check the following article.

http://msdn.microsoft.com/msdnmag/issues/03/08/datagrids/

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
C

Cor Ligthert

Dave,

Beside that Kevin did give you an answer in C# did he you in my opinion the
right answer. When he had not used the method headers, { ; and } he had
given VBNet code.

When you have problems how to build that thirth table, reply than. I think
that it is good to give a distinct in the rows from the new table by using
an extra column where you put in the code 1 and 2. I thought with that you
could not standard create a different color in the basic datagridrows,
however there are as far as I know posibilities and because Ken does that
forever we have than to wait (when he knows that) on his answer for the
right link or code.

Cor
 
D

Dave

I propably approched this problem incorrectly.

A more efficient way of doing what i need it is to put the data in 1 row -
but dispaly the data in the datagrid in 2 rows.

Is they way to do this with Microsoft datagrid - it look like there are
someother third pary datagrids that allow you to display 1 row of data into
2 rows on the datagrid.

thanks

Dave
 
K

Kevin Yu [MSFT]

Hi Dave,

As far as I know, we cannot do this with MS's datagrid. Maybe there is some
3rd-party controls to achieve this. Or you can try to inherit from the
current data grid and implement your own. :)

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
M

meancoder

There is a way to do it.
1. Make the last column of datagrid a template column.
2. Add placeholder as last control in template column
3. Build a function RowFunc() that returns a complete HTML row except
the last starting with <TR><TD>, but does not return the very
last"</td></tr>"
4. in itemdatabinding function say something like
PlaceHolder.Controls.add(New literalcontrol("</td></tr>"))
5. Placeholder.Controls.add(new literalcontrol(RowFunc()))
6. Datagrid will automatically add closing table cell and table row
tags because it is clueless about us inserting another row
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top