In one cell of a datagridview I want to put two buttons. I got this to work
easily using
thisButton = new HtmlButton();
e.Row.Cells[5].Controls.Add(thisButton);
thisButton = new HtmlButton();
e.Row.Cells[5].Controls.Add(thisButton);
======BUT=====
I want them to be centered, at least horizontally, and one below the other,
not in a straight line like the above gives.
The best I could get this to come out was to use a negative pixel offset on
the second button and make it relative as in ...
thisButton.Style.Add(HtmlTextWriterStyle.Top, "0px");
thisButton.Style.Add(HtmlTextWriterStyle.Position, "static");
e.Row.Cells[5].Controls.Add(thisButton);
thisButton = new HtmlButton();
thisButton.Style.Add(HtmlTextWriterStyle.Position, "relative")
thisButton.Style.Add(HtmlTextWriterStyle.Top, "32px");
thisButton.Style.Add(HtmlTextWriterStyle.Left, "-64px");
I tried various combinations of setting the grid control field item style
alignment, but I could not get away from using the -64px which moves the
second button to the left by the width of the first button which is 64. The
height of both buttons is 32 so that is why the "Top" was set to 32 on the
second button.
Is there a cleaner way to do this where I dont have to specify a negative
pixel. I turned on wrap, but that did nothing.
..thanks..
Sergey Poberezovskiy - 17 Aug 2007 03:12 GMT
why not insert a break rule in between the buttons, and make the cell centered?
TableCell cell = e.Row.Cells[5];
ControlCollection controls = cell.Controls;
thisButton = new HtmlButton();
controls.Add(thisButton);
controls.Add(new Literal("<br/>");
thisButton = new HtmlButton();
controls.Add(thisButton);
cell.HorizontalAlign = HorizontalAlign.Center;
> In one cell of a datagridview I want to put two buttons. I got this to work
> easily using
[quoted text clipped - 27 lines]
>
> ...thanks..
Joe Stateson - 17 Aug 2007 16:50 GMT
> why not insert a break rule in between the buttons, and make the cell
> centered?
[quoted text clipped - 7 lines]
> controls.Add(thisButton);
> cell.HorizontalAlign = HorizontalAlign.Center;
thanks Sergey, that did it. I changed the above literal code to ..
Literal thisLiteral = new Literal();
thisLiteral.Text = "<br/>";