# Owl's Blog on .NET development

Component Owl codes Better ListView control all night so you don't have to.

## Customize Label Editing (Embedded) Control for Each Line in Better ListView

Blog Post by Libor Tinka published on Wednesday, 04 April 2012 in Better ListView, Tutorials

Embedded controls for label edit in Better ListView can be customized not only for every column, but even for every row.

This is not a new feature, but would be nice to mention that you can possibly have a different custom editing control for every cell…

C#

[csharp gutter=”false” toolbar=”false”]
private IBetterListViewEmbeddedControl ListViewRequestEmbeddedControl(object sender, BetterListViewRequestEmbeddedControlEventArgs eventArgs)
{
// show editing controls in the second column
if (eventArgs.SubItem.Index == 1)
{
// show my custom control on the first row
if (eventArgs.SubItem.Item.Index == 0)
{
return (new DocumentAccessConrol());
}

// show my custom control on the second row
if (eventArgs.SubItem.Item.Index == 1)
{
return (new BetterListViewComboBoxEmbeddedControl());
}

// show my custom control on the third row
if (eventArgs.SubItem.Item.Index == 2)
{
return (new BetterListViewTextBoxEmbeddedControl());
}
}

return null;
}
[/csharp]

Visual Basic

[vb gutter=”false” toolbar=”false”]
Private Function ListViewRequestEmbeddedControl(ByVal sender As Object, ByVal eventArgs As BetterListViewRequestEmbeddedControlEventArgs) _
As IBetterListViewEmbeddedControl

‘ show editing controls in the second column
If eventArgs.SubItem.Index = 1 Then

‘ show my custom control on the first row
If eventArgs.SubItem.Item.Index = 0 Then
Return (New DocumentAccessConrol())
End If

‘ show my custom control on the second row
If eventArgs.SubItem.Item.Index = 1 Then
Return (New BetterListViewComboBoxEmbeddedControl())
End If

‘ show my custom control on the third row
If eventArgs.SubItem.Item.Index = 2 Then
Return (New BetterListViewTextBoxEmbeddedControl())
End If

End If

Return Nothing

End Function
[/vb]

And there is the result:

Custom Embedded Control on the First Line

TextBox Control on the Third Line

Tags: better listview, controls, custom, different, edit, editing, embedded, label, per-line, specific

### 2 Responses to “Customize Label Editing (Embedded) Control for Each Line in Better ListView”

1. Göran says:
   April 25, 2012 at 10:53 am

   There is a tiny error in the VB code below “‘ show my custom control on the third row”.
   The index should be “2”, not “0”.

   :-)

   Thanks for a great product and for a great and humorous site!

   /G

   - Libor Tinka says:
     April 25, 2012 at 1:57 pm

     Thanks for noticing… I have corrected it.

### Leave a Reply

Click here to cancel reply.

Name (required)

Mail (will not be published) (required)

Website