如:
得到了一组衣服尺码的数据
52B 53A 54B 52B 53A 54B 52B 54B 52A 52B 53B 54A 45B 46A 54B 52A 56B 如何在datagrid里显示
52B(5)
53A(2)
54B(3)
....
这样,谢谢!
得到了一组衣服尺码的数据
52B 53A 54B 52B 53A 54B 52B 54B 52A 52B 53B 54A 45B 46A 54B 52A 56B 如何在datagrid里显示
52B(5)
53A(2)
54B(3)
....
这样,谢谢!
我写了个给你,用SQL写比较好,不过我这里没装SQL不好写。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace WindowsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
string str = "52B 53A 54B 52B 53A 54B 52B 54B 52A 52B 53B 54A 45B 46A 54B 52A 56B";
string[] strArr = str.Split(new char[] { ' ' });
ArrayList al = new ArrayList();
for(int i=0;i<strArr.Length;i++)
{
al.Add(strArr[i]);
}
ArrayList alResult = new ArrayList();
for (int i = al.Count-1; i > -1; i--)
{
string strTmp = al[i].ToString();
al.RemoveAt(i);
int iCount = 1;
for(int j=0;j<al.Count;j++)
{
int index = al.IndexOf(strTmp);
if(index<0)
{
break;
}
iCount++;
al.RemoveAt(index);
i--; }
alResult.Add(strTmp+"("+iCount.ToString()+")");
}
string strt = string.Empty;
for(int i=0;i<alResult.Count;i++)
{
strt+="\n\r"+alResult[i].ToString();
}
MessageBox.Show(strt);
}
}
}
SQL = "Select A_Class From A_Brand where A_Class in(Select A_Brand_Class from A_Product) group by A_Class order by A_Class desc"
用聚合函数