Professional Documents
Culture Documents
Sign in
home
articles
quick answers
discussions
Ask a Question
features
community
help
FAQ
C#
DataGridView
Rate this:
pdfcrowd.com
Top Experts
Posted 30-Jan-11 23:52pm Edited 31-Jan-11 1:14am v2
gksdy2000 306
Last 24hrs
This month
OriginalGriff
254 OriginalGriff
1,028
Dave Kreskowiak
80 Sascha Lefvre
355
315
Also Read
no
Solution 1
421
Comments
5 solutions
110 phil.o
Jochen Arndt
594
Top Rated
Most Recent
Rate this:
I think, it will be better if you merge tables first and then bind Gridview to
that table.
Related Questions
Merging Excel file Rows on Equal value through
C#
How to merge rows with equal values in a
pdfcrowd.com
Comments
Merge cells
Solution 8
Copy Code
void Compare()
{
DataTable dt = GetDataTable();
DataView dv = new DataView(dt);
String strAtual = String.Empty;
foreach (DataRowView row in dv)
{
if
(strAtual.Equals(row.Row["OrderId"].ToString()))
{
foreach (DataColumn dataColumn in
dv.Table.Columns)
{
String columnName =
(dataColumn.ColumnName);
if (columnName != "OrderId")
{
pdfcrowd.com
string strTagNumb =
row[columnName].ToString();
CompareDelete(strTagNumb, strAtual,
dv, columnName);
}
}
row.Delete();
continue;
}
if
(!string.IsNullOrEmpty(row.Row["OrderId"].ToString()))
strAtual = row.Row["OrderId"].ToString();
}
dataGridView2.DataSource = dv;
}
Posted 12-Feb-15 20:25pm
private void
Member 10554801
457 CompareDelete(string strTagNumb, string
strAtual, DataView dt, String columnName)
{
foreach (DataRowView row in dt)
{
if
(row.Row["OrderId"].ToString().Equals(strAtual))
{
string nl = Environment.NewLine;
Rate this:
row.Row[columnName] += string.Concat(nl,
strTagNumb);
return; I provided you with links in my answer
Thanks for the good question.
}
above. But I've also tried to solve this problem by myself.
}
The following
code demonstrates how you can merge cells and keep it
}
Solution 5
Copy Code
using System;
pdfcrowd.com
using
using
using
using
using
using
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Text;
System.Windows.Forms;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
DataGridView dataGrid;
DataSet dataSet;
Button button;
private List<string> MergedRowsInFirstColumn = new
List<string>();
private bool readyToMerge = false;
public Form1()
{
InitializeComponent();
CreateGridAndButton();
}
private void CreateGridAndButton()
{
dataGrid = new DataGridView();
dataSet = new DataSet();
dataGrid.Height = this.Height - 100;
dataGrid.Dock
= DockStyle.Top;
Posted 1-Feb-11
10:31am
dataGrid.ReadOnly
= true;
Tim__James 1.6K
dataGrid.AllowUserToAddRows = false;
dataGrid.AllowUserToResizeRows = false;
dataGrid.RowHeadersVisible = false;
Comments
this.dataGrid.Paint += new
PaintEventHandler(dataGrid_Paint);
gksdy2000 1-Feb-11 18:47pm
pdfcrowd.com
Solution 4
Rate this:
Hi,
I did it a few weeks ago, follow the cobe below:
open in browser PRO version
pdfcrowd.com
Hide Expand
Copy Code
pdfcrowd.com
Comments
Timur Akhmedov 31-Jan-11 9:22am
Could you elaborate how does it w ork? I don't see cells merging here...
-Timur
pdfcrowd.com
Solution 3
Rate this:
pdfcrowd.com
>
Preview
Existing Members
open in browser PRO version
...or Join us
Are you a developer? Try out the HTML to PDF API
pdfcrowd.com
Existing Members
...or Join us
Your Email
Your Email
Password
Optional Password
Forgot your password?
I have read and agree to the
and Privacy Policy
Please subscribe me to the CodeProject
newsletters
This content, along with any associated source code and files, is licensed under The
Code Project Open License (CPOL)
pdfcrowd.com
CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100
pdfcrowd.com