The separator that you see in the control DataRepeaterbetween the elements is a drawing on the non-client area of the control DataRepeaterItem.
You can find those DataRepeaterItemand process those messages WM_NCPAINTand draw a line with the same color as the element BackColoror any other color you want from (0, Height-1)to (Width-1, Height-1).
Implementation
, NativeWindow, , handle :
using Microsoft.VisualBasic.PowerPacks;
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public class DataRepeaterItemHelper : NativeWindow
{
private DataRepeaterItem item;
private const int WM_NCPAINT = 0x85;
[DllImport("user32.dll")]
static extern IntPtr GetWindowDC(IntPtr hWnd);
[DllImport("user32.dll")]
static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
public DataRepeaterItemHelper(DataRepeaterItem repeaterItem)
{
item = repeaterItem;
this.AssignHandle(item.Handle);
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_NCPAINT)
{
var hdc = GetWindowDC(m.HWnd);
using (var g = Graphics.FromHdcInternal(hdc))
using (var p = new Pen(item.BackColor, 1))
g.DrawLine(p, 0, item.Height - 1, item.Width - 1, item.Height - 1);
ReleaseDC(m.HWnd, hdc);
}
}
}
DrawItem DataRepeater , DataRepeaterItemHelper e.DataRepeaterItem . , . DataRepeater DataRepeaterItemHelper , DrawItem. , DataRepeaterItemHelper, List<DataRepeaterItem>:
new List<DataRepeaterItem> items = new List<DataRepeaterItem>();
void HandleItem(DataRepeaterItem item)
{
if (items.Contains(item))
return;
var handler = new DataRepeaterItemHelper(item);
items.Add(item);
}
private void Form1_Load(object sender, EventArgs e)
{
var db = new TestDBEntities();
this.dataRepeater1.DataSource = db.Category.ToList();
this.dataRepeater1.Controls.OfType<DataRepeaterItem>().ToList()
.ForEach(item => HandleItem(item));
this.dataRepeater1.DrawItem += dataRepeater1_DrawItem;
}
void dataRepeater1_DrawItem(object sender, DataRepeaterItemEventArgs e)
{
HandleItem(e.DataRepeaterItem);
}
:

:
Form1_Load Load. dataRepeater1_DrawItem DrawItem. Form1_Load .DataRepeater.