本文介绍了我想将单元格拆分为网格线中的多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以上帝的名义
嗨
我想将单元格拆分为gridline中的多行
例如,一个人有几份工作,我想将他的所有工作都显示在一行中
这意味着他所有在工作中显示的工作都标有工作
如果您知道合适的软件或好的解决方案,我需要您的帮助
样本:
名称------职位
jhon ------程序员
----------店主
---------- driver
In the name Of God
hi
i want to split a cell to multiple rows in gridline
for example a person has several job i want to show it in one row with all his job
it means all his job show in cell which taged with job
if you know suitable software or know good solution i need your help
sample:
name------job
jhon------programmer
----------shopkeeper
----------driver
推荐答案
DataTable dt = all data from database;
DataTable dtCurrent = new DataTable();
bool found = false;
dtCurrent = dt;
for (int i=0 ; i< dt.rows.count;i++)
{
int ID = dt.rows(i)("ID");
//you need another for loop to compare temporary data with another in the same grid.
//here you can use list<string> or arraylist to add job data.
List<string> lst = new List<string>;
for (int j=0; j<dt.rows.count;> {
if (dt.rows(j)("ID") == ID)
lst.Add(row(j)("JobName"));
}
//don't forget using System.Text
StringBuilder str = new StringBuilder();
for(int l =0; i<lst.count;> {
str.AppendFormat("{0},",lst(l).ToString(),Environment.NewLine);
}
for(int current = 0; current < dtCurrent.rows.count; current++)
{
if(dtCurrent.rows(current)("ID") == ID && found == false)
{
found = true;
dtCurrent(current)("JobName") = str.ToString();
}
if (found)
{
if(dt.rows(current)("ID") == ID)
{
dt.rows(current).delete();
}
}
}
}
grid.datasource = dt;</string></string></string>
这篇关于我想将单元格拆分为网格线中的多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!