Hack Forums
[.NET] Drawing control - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Drawing control (/showthread.php?tid=4381063)



Drawing control - edin_ - Aug 6, 2014

Ok, I'm trying to draw textbox on form with 'form load sub' and It's working with default windows form theme, but when you add custom form theme onto form, drawn textbox can't be visible

code:

PHP Code

<?php 
Dim txt 
As New TextBox
txt
.Width = 40
txt
.Height = 37
txt
.BorderStyle = BorderStyle.None
txt
.BackColor = Color.Black
txt
.ForeColor = Color.White
txt
.Font = New Font("Arial", 22)
txt.BringToFront()
Me.Controls.Add(txt)

'I try with SendToBack() on custom form but neither that work 


Big Image Spoiler (Click to View)


* - Only3 - Aug 6, 2014

Me.Controls.Add(txt) > CustomForm.Controls.Add(txt)


* - edin_ - Aug 6, 2014

(Aug 6, 2014 10:53 AM)Only3 Wrote:  Me.Controls.Add(txt) > CustomForm.Controls.Add(txt)

I tried that but no luck

Spoiler (Click to View)


* - Only3 - Aug 6, 2014

its work try this code and play with the location
Dim txt As New TextBox
txt.Width = 40
txt.Height = 37
txt.BorderStyle = BorderStyle.None
txt.BackColor = Color.Black
txt.ForeColor = Color.White
txt.Font = New Font("Arial", 22)
txt.Location = New Point(10, 10)
CustomForm.Controls.Add(txt)


* - edin_ - Aug 6, 2014

@Only3 thanks but I figured out where I make mistake, I add txt.BringToFront() before adding control to form. It must be after Me.Controls.Add(txt)
txt.BringToFront()


* - Only3 - Aug 6, 2014

u dont really need bringtofront it will work without it too


* - SIM-1456245 - Aug 6, 2014

Hence this is solved, I'll give ya a tip whenever you are fucking around with custom controls like this. Always copy the code from the designer, it lowers the frustration quite a bit, but if you are trying to do dynamic list kind of stuff, go with a flow panel, aligns everything nicely.