我目前学用DotNetBar的SuperGrid,做的窗口真漂亮,但是我以前用PowerBuiler的,有过滤重复值功能就比如我一条SELECT语句结果是姓名 年份 工作地点
张三 2001 广州
张三 2003 深圳
张三 2007 上海
李四 2005 广州
张四 2008 深圳
李四 2009 上海
王五 2013 深圳
我要在SuperGrid显示的效果是姓名 年份 工作地点
张三 2001 广州
2003 深圳
2007 上海
李四 2005 广州
2008 深圳
2009 上海
王五 2013 深圳应该SuperGrid与DataGridView用法差不多吧,只不过前者有很多特色的功能
张三 2001 广州
张三 2003 深圳
张三 2007 上海
李四 2005 广州
张四 2008 深圳
李四 2009 上海
王五 2013 深圳
我要在SuperGrid显示的效果是姓名 年份 工作地点
张三 2001 广州
2003 深圳
2007 上海
李四 2005 广州
2008 深圳
2009 上海
王五 2013 深圳应该SuperGrid与DataGridView用法差不多吧,只不过前者有很多特色的功能
DotNetBar的SuperGridControl应该有属性吧,这么强大的控件,没人用过吗
using System.Collections.Generic;
namespace GeZhongTest
{
/// <summary>
/// 泛型去重复比较类
/// </summary>
class ListComparer:IEqualityComparer<string>
{
public bool Equals(string a, string b)
{
if (a == b)
{
return true;
}
else
{
return false;
}
}
public int GetHashCode(string obj)
{
return 0;
}
}
}
static void Main(string[] args)
{
List<string> list = new List<string>();
for (int i = 0; i < 5; i++)
{
list.Add("shenme" + i);
}
list.Add("shenme2");
list.Add("shenme3");
for (int j = 10; j < 15; j++)
{
list.Add("ha" + j);
}
list.Add("ha12");
Console.WriteLine("去重之前");
Console.WriteLine("******************************");
foreach (string eve in list)
{
Console.Write(eve + "\t");
}
Console.WriteLine("******************************");
Console.WriteLine("去重之后");
Console.WriteLine("******************************");
//调用方法去重复
var resultList = list.Distinct(new ListComparer());
foreach(var item in resultList)
{
Console.Write(item.ToString() + "\t");
}
Console.WriteLine("******************************");
Console.ReadKey();
}
using System.Windows.Forms;
/// <summary>
///GridViewMergeCell 合并GridView
/// </summary>
public class GridViewMerge
{
public static void spanRow(SuperGridControl dg, string GroupColumn)
{
int i = 0;
int j = 0;
int rowSpan;
string strTemp = "";
string strTemp2 = "";
GridElement col;
GridRow a; for (i = 0; i < dg.PrimaryGrid.Rows.Count; i++)
{
rowSpan = 1;
col = dg.PrimaryGrid.Rows[i];
a = col as GridRow;
strTemp = a.Cells[GroupColumn].Value.ToString();
for (j = i + 1; j < dg.PrimaryGrid.Rows.Count; j++)
{
col = dg.PrimaryGrid.Rows[j];
a = col as GridRow;
strTemp2 = a.Cells[GroupColumn].Value.ToString(); if (string.Compare(strTemp, strTemp2) == 0)
{
rowSpan += 1;
//dg.Items[i].Cells[GroupColumn].RowSpan = rowSpan;
//dg.Items[j].Cells[GroupColumn].Visible = false;
a.Cells[GroupColumn].Visible = false;
}
else
{
break;
}
}
i = j - 1;
}
}
}
FpSpread1.Sheets(i).SetColumnMerge(0, Model.MergePolicy.Always)