By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,082 Members | 2,108 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,082 IT Pros & Developers. It's quick & easy.

DataGrid - 2 table comparisons

P: n/a
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


Nov 21 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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
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

Nov 21 '05 #2

P: n/a
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

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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
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


Nov 21 '05 #3

P: n/a
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/is.../08/datagrids/

HTH.

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

Nov 21 '05 #4

P: n/a
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
"Dave" <Da**********@hotmail.com>
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

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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
> 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
>
>
>
>



Nov 21 '05 #5

P: n/a
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


"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:$e**************@cpmsftngxa06.phx.gbl...
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/is.../08/datagrids/

HTH.

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

Nov 21 '05 #6

P: n/a
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."

Nov 21 '05 #7

P: n/a
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

Nov 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.