我想将单元格拆分为网格线中的多行 [英] i want to split a cell to multiple rows in gridline

查看:118
本文介绍了我想将单元格拆分为网格线中的多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以上帝的名义


我想将单元格拆分为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

推荐答案

填充网格时(在填充网格函数中),您需要循环数据表行并检查重复的ID(主要是),并将其存储在临时变量中,然后在相等时使用字符串生成器将其与所有作业数据附加到其中,然后将其与数据表中的其他行进行比较.

然后将数据表绑定到您的网格.

例如
when fill grid (in fill grid function) you need loop datatable rows and checks when repeated the ID(Primary), and store it in temporary variable then compare it with another rows in datatable when equal use string builder to append all job data inside it.

then bind datatable to your grid.

Ex.
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>


这篇关于我想将单元格拆分为网格线中的多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆