简体   繁体   中英

How to split cell of a grid into columns winforms devexpress

I would like learn something. I have a GridControl which has a gridview inside with some columns. And there's one column lets name "jobs". in my DataList (which i'm populating rows with) i have another list which will hold some infos about jobs and i want to show them in one column. But there's the problem. I want to split the cell of "jobs" . how can i do that?

the model and the list is like below:

//this is my job class
public class JobInfo{
   public string Name;
   public bool IsDone;
}

//this is my work class
public class Work{
   public string Company;
   public string Personel;
   public List<JobInfo> Jobs;
}

in my cs file I will hold a List<Work> object. I can bound it to grid view but i want to show job info like that cell contains 4 or 5 cells or how many jobs that list has.

I tried some paint to be as clear as much http://imgur.com/eEB9krO

Any help appreciated. Thanks

You can not have columns inside columns in a GridView.

How about just adding it into one cell like this?

private void gridView_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
{
    if (e.Column.FieldName == "Jobs")
    {
        var jobs = e.Value as List<JobInfo>;
        e.DisplayText = jobs != null ? 
                        string.Join(" | ", jobs.Select(j => string.Format("Name: {0}, Is Done: {1}", j.Name, j.IsDone))) : 
                        string.Empty;
    }
}

There is no way to do exactly what you need. But maybe it is an option to use a repositoryItem. You could use a popupcontaineredit. Then you build a popupcontainercontrol with a new Grid. If someone click a row or on the dropdown of your popupcontaineredit you can popup your popupcontainercontrol and populate the list of jobs in the uppoping grid.

I hope you understand what i mean.

regards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM