Yes, ListView supports custom drawing by setting the OwnerDraw property to True. That tends to be elaborate but your needs are simple, you can use a lot of the default drawing here. Only when an item is selected do you need something different. The ControlPaint class can draw the dotted rectangle you want. Implement the three Draw event handlers, something like this:
private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e) {
e.DrawDefault = true;
}
private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e) {
e.DrawBackground();
e.DrawText();
if ((e.State & ListViewItemStates.Selected) == ListViewItemStates.Selected) {
var bounds = e.Bounds;
bounds.Inflate(-1, -1);
ControlPaint.DrawFocusRectangle(e.Graphics, bounds);
}
}
private void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) {
e.DrawBackground();
e.DrawText();
if ((e.ItemState & ListViewItemStates.Selected) == ListViewItemStates.Selected) {
var bounds = e.Bounds;
bounds.Inflate(-1, -1);
ControlPaint.DrawFocusRectangle(e.Graphics, bounds);
}
}
Tweak as desired. Do note that you probably also want to implement the MouseDown event so the user can click any sub-item and select the row. It isn't clear anymore that this behaves like a ListView. Use the HitTest() method to implement that.