For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > July 2004 > drawing lines on a webform









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author drawing lines on a webform
Paul

2004-07-29, 8:56 pm

Hi just wondering if there is an easy way to a box around a bunch of controls like
-----------------------------------------------------
| control1 control2 control3 |
| |
----------------------------------------------------
thanks,


--
Paul G
Software engineer.
Mythran

2004-07-29, 8:56 pm

Try a panel with borders set?

Or...

Private Sub DrawBorder(ByVal Controls As Control())
Dim x1 As Integer = Integer.MaxValue
Dim x2 As Integer = Integer.MinValue
Dim y1 As Integer = Integer.MaxValue
Dim y2 As Integer = Integer.MinValue
Dim graph As Graphics = Me.CreateGraphics()
Dim pen As Pen
Dim rect As Rectangle

For Each Control As Control In Controls
x1 = Min(x1, Control.Left)
x2 = Max(x2, Control.Left + Control.Width)
y1 = Min(y1, Control.Top)
y2 = Max(y2, Control.Top + Control.Height)
Next

' Draw the borders around the controls.
pen = New Pen(Color.Blue, 1)
rect = New Rectangle(x1 - 4, y1 - 4, (x2 - x1) + 4, (y2 - y1) + 4)
graph.DrawRectangle(pen, rect)
End Sub

Private Function Max(ByVal Num1 As Integer, ByVal Num2 As Integer) As Integer
Return IIf(Num1 > Num2, Num1, Num2)
End Function

Private Function Min(ByVal Num1 As Integer, ByVal Num2 As Integer) As Integer
Return IIf(Num1 < Num2, Num1, Num2)
End Function

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim controls As Control() = New Control() { _
Checkbox1, Checkbox2, Checkbox3, Checkbox4, Checkbox5, Checkbox6 _
}

DrawBorder(controls)
End Sub

"Paul" <Paul@discussions.microsoft.com> wrote in message
news:B099A2D1-6F55-4805-9CD1-8367592875C5@microsoft.com...
> Hi just wondering if there is an easy way to a box around a bunch of controls

like
> -----------------------------------------------------
> | control1 control2 control3 |
> | |
> ----------------------------------------------------
> thanks,
>
>
> --
> Paul G
> Software engineer.



Mythran

2004-07-29, 8:56 pm

WOAH!!! Sorry, I did that..but it's for WinForms :P Sorry about that heh.

As for your REAL answer...

<table style='width:75%;border:1px Solid Black;'>
<tr>
<td>
<asp:label ... blah ...>blah</asp:label>
</td>

<td>
<asp:label ... blah ...>blah</asp:label>
</td>

<td>
<asp:label ... blah ...>blah</asp:label>
</td>
</tr>
</table>

And another example...using non-html controls (meaning asp.net controls...which
still use html controls behind the scenes):

<asp:panel style='border:1px Solid Black;' ... blah ...>
<asp:label style='width:100px;' ... blah ...>blah</asp:label>
<asp:label style='width:100px;' ... blah ...>blah</asp:label>
<asp:label style='width:100px;' ... blah ...>blah</asp:label>
</asp:panel>

"Paul" <Paul@discussions.microsoft.com> wrote in message
> news:B099A2D1-6F55-4805-9CD1-8367592875C5@microsoft.com...
> like
>
>



Paul

2004-07-29, 8:56 pm

ok thanks for the information. Looks like the panel control will work for some of the stuff I am grouping. Also was wondering if you know how to close a htm file that includes a frame? I am trying to setup a log off button and tried java script like
<script language="javascript" event="onclick()" for="Button2">
window.close();
</script>
I have a frame, htm file that contains 2 aspx files,
<frame name="main" src="default.aspx">
<FRAME src="contents.aspx">
I have the log off button on the contents.aspx form, tried client side script in the html for contents but this did not close the window.
Thanks
but did not work.
The

--
Paul G
Software engineer.


"Mythran" wrote:

> WOAH!!! Sorry, I did that..but it's for WinForms :P Sorry about that heh.
>
> As for your REAL answer...
>
> <table style='width:75%;border:1px Solid Black;'>
> <tr>
> <td>
> <asp:label ... blah ...>blah</asp:label>
> </td>
>
> <td>
> <asp:label ... blah ...>blah</asp:label>
> </td>
>
> <td>
> <asp:label ... blah ...>blah</asp:label>
> </td>
> </tr>
> </table>
>
> And another example...using non-html controls (meaning asp.net controls...which
> still use html controls behind the scenes):
>
> <asp:panel style='border:1px Solid Black;' ... blah ...>
> <asp:label style='width:100px;' ... blah ...>blah</asp:label>
> <asp:label style='width:100px;' ... blah ...>blah</asp:label>
> <asp:label style='width:100px;' ... blah ...>blah</asp:label>
> </asp:panel>
>
> "Paul" <Paul@discussions.microsoft.com> wrote in message
>
>
>

Mythran

2004-07-30, 3:58 pm

Hrm..

a frame page eh? Try window.parentWindow.close() or window.parent.close() or
something to that effect (window.top.close() should do the trick).

Mythran



"Paul" <Paul@discussions.microsoft.com> wrote in message
news:A88D6C54-21E0-46EA-93D8-D19C3316C2DB@microsoft.com...
> ok thanks for the information. Looks like the panel control will work for some

of the stuff I am grouping. Also was wondering if you know how to close a htm
file that includes a frame? I am trying to setup a log off button and tried
java script like
> <script language="javascript" event="onclick()" for="Button2">
> window.close();
> </script>
> I have a frame, htm file that contains 2 aspx files,
> <frame name="main" src="default.aspx">
> <FRAME src="contents.aspx">
> I have the log off button on the contents.aspx form, tried client side script

in the html for contents but this did not close the window.[color=darkred]
> Thanks
> but did not work.
> The
>
> --
> Paul G
> Software engineer.
>
>
> "Mythran" wrote:
>
controls...which[color=darkred]
controls[color=darkred]


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com