Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / August 2007

Tip: Looking for answers? Try searching our database.

problem ordering buttons vertically in cell

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joe Stateson - 16 Aug 2007 23:05 GMT
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/>";

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.