Firstly I created two simple entity classes named Article and Comment :
Article.cs :
using System.Collections.Generic;
namespace DevexMasterChildSample
{
public class Article
{
public string Subject { get; set; }
public string Body { get; set; }
public List<Comment> CommentList { get; set; }
}
}
Comment.cs
using System;
namespace DevexMasterChildSample
{
public class Comment
{
public string Author { get; set; }
public string Message { get; set; }
public DateTime CommentDate { get; set; }
}
}
Then I Added a simple Windows form file to my project named Form1.cs and in Design Mode I draged a Devexpress GridControl to my form and changed it’s size to fit my form.
After that I created a new level for Gridview1 shown below
Then I renamed the Level to CommentList it must be exactly the same with Master Object’s child collection property name. In this case it is CommentList on Article object
Form1.cs
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace DevexMasterChildSample
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
List<Article> articles = new List<Article>();
articles.Add(new Article
{
Body = "Bu yazı devexpress gridcontrolü anlatmaktadır.",
CommentList =
new List<Comment>
{
new Comment
{
Author = "Erdem",
CommentDate = DateTime.Now,
Message = "Yazınız güzel olmuş."
}
},
Subject = "Devexpress GridControl master Child Örnek"
});
articles.Add(new Article
{
Body = "Bu yazı devexpress treeview anlatmaktadır.",
CommentList =
new List<Comment>
{
new Comment
{
Author = "Alkan",
CommentDate = DateTime.Now,
Message = "Yazınız pek anlaşılır olmamış."
}
},
Subject = "Devexpress Treeview Drag-drop Örnek"
});
gridControl1.DataSource = articles;
}
}
}





Son Yorumlar