I prefer to use hyperlink-style text, overriding the drawing code and handling mouse / mouse click events, since the buttons do not scale too well to the typical grid line height. However, if the button is really what you want, you should do it using RepositoryItemButtonEdit as the type of editor.
If you are interested in the first, leave a comment, and I will update it with an example. Otherwise, as already mentioned, just use RepositoryItemButtonEdit . You can change its properties to take the whole cell if you want, and then make the column a fixed size so that the button does not stretch.
UPDATE: I am posting some sample code for the “pretty hyperlink” below, which I like a lot better than the standard hyperlink cell, because (a) it looks better, (b) it gives feedback with the hang, and (c) you can change the cursor if you want (I use the utility method to get my own mouse cursor from the OS, which has a more three-dimensional appearance than the one built into Winforms).
Note for non-DevExpress users who read this: I use an almost identical method for the standard System.Windows.Forms.ListView . Microsoft uses this user interface pattern quite a bit in Vista and Windows 7, and it's good to learn how to do it, even if the result is not a perfect replica.
private int hoverRowHandle = GridControl.InvalidRowHandle; private void gridView_Click(object sender, EventArgs e) { if (hoverRowHandle != GridControl.InvalidRowHandle) { MyItem item = gridView.GetRow(hoverRowHandle) as MyItem; if (item != null) // Do whatever the "click" action is here } } private void gridView_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e) { if (e.Column == linkColumn) { bool hover = (hoverRowHandle == e.RowHandle); FontStyle style = hover ? FontStyle.Underline : FontStyle.Regular; TextFormatFlags formatFlags = TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.WordEllipsis; Color foreColor = gridView.IsRowSelected(e.RowHandle) ? Color.White : (hover ? MyColors.LinkHover : MyColors.Link); using (Font font = new Font(gridControl.Font, style)) { TextRenderer.DrawText(e.Graphics, "Link Text", font, e.Bounds, foreColor, formatFlags); } e.Handled = true; } } private void gridView_MouseLeave(object sender, EventArgs e) { int tempRowHandle = hoverRowHandle; hoverRowHandle = GridControl.InvalidRowHandle; if (tempRowHandle != GridControl.InvalidRowHandle) { gridView.InvalidateRowCell(tempRowHandle, linkColumn); } } private void gridView_MouseMove(object sender, MouseEventArgs e) { int tempRowHandle = hoverRowHandle; if (tempRowHandle != GridControl.InvalidRowHandle) { hoverRowHandle = GridControl.InvalidRowHandle; gridView.InvalidateRowCell(tempRowHandle, linkColumn); } GridHitInfo hitInfo = gridView.CalcHitInfo(e.Location); if (hitInfo.InRowCell && (hitInfo.Column == linkColumn)) { hoverRowHandle = hitInfo.RowHandle; gridView.InvalidateRowCell(hoverRowHandle, linkColumn); } bool hoverDetail = (hoverRowHandle != GridControl.InvalidRowHandle); gridControl.Cursor = hoverDetail ? Cursors.Hand : Cursors.Default; }
A few comments about this code:
MyItem is any type of data that you have attached to a grid view. Maybe it's a DataRow , or maybe some kind of user-defined type if the data source is IList<T> .
MyColors is a utility class that defines a pair of public static readonly Color fields used for user interface content. You can replace links to this with hard-coded colors if you are only going to do it on the same grid.
I am not trying to cache Font , although you probably could, since there are only two of them.
The cursor logic will work with any other cursor logic that you can use in the grid (for me, there are almost no cases, therefore, as a rule, everything should be fine).
If you want to have more than one link column, you need to save the hoverColumn status hoverColumn in addition to hoverRowHandle and obviously change these comparisons with a single column to search for multiple columns.
For my own Winforms applications, I actually have an Extender provider that allows me to attach this behavior to a GridView or ListView by flipping the column name / text to the column list, but this code is just a tiny bit too long to post here. In the above example you should start.