I would like to add a custom method for each row i.e. an open detail form that show details for the grid row the button has been clicked for.
Is there any easy solution for that?
EDIT:
What's wrong with my code to style the button?
Image img = imageList1.Images[5];
repositoryItemButtonEdit1.Buttons.Clear();
repositoryItemButtonEdit1.Buttons.Add(new EditorButton(ButtonPredefines.Left, "View Filter", 16, true, true, true, ImageLocation.Default, img));
repositoryItemButtonEdit1.ButtonPressed += new ButtonPressedEventHandler(repositoryItemButtonEdit1_ButtonPressed);
ANSWER (use Glyph)
Image img = imageList1.Images[5];
repositoryItemButtonEdit1.Buttons.Clear();
repositoryItemButtonEdit1.Buttons.Add(
new EditorButton(
ButtonPredefines.Glyph,
"",
16,
true,
true,
true,
ImageLocation.Default,
img
)
);
repositoryItemButtonEdit1.ButtonPressed += newButtonPressedEventHandler(repositoryItemButtonEdit1_ButtonPressed);
The easiest way to do that is to add a RepositoryItemButtonEdit
as the ColumnEdit
for the column.
Make sure you set the TextEdit
property of the RepositoryItemButtonEdit to hidden, and configure the buttons property so that it has your image button.
Then handle the ButtonPressed Event
of the repository item.
A simple event handler might look something like:
c#
private void RepositoryItemButtonEdit1_Click(object sender, System.EventArgs e)
{
WhateverClass MyData = (WhateverClass)GridView1.GetFocusedRow();
Form1 frmEdit = new Form1(MyData);
frmEdit.Show();
}
vb.net
Private Sub RepositoryItemButtonEdit1_Click(sender As Object, e As System.EventArgs) Handles RepositoryItemButtonEdit1.Click
Dim MyData As WhateverClass= CType(GridView1.GetFocusedRow(), WhateverClass)
Dim frmEdit As New Form1(MyData)
frmEdit.Show()
End Sub