vb.net - Visual basic: picuter border on a button. How to? -


heey, i've been searching till brain hurts answer "how add border button" general idea have button portrait of person, button needs border (green or red) indicate whether person online or offline. buttons generated in runtime of have happen through code. note these buttons generated using count of rows in database (dtactive) how buttons generated:

public sub generateusers()     dim contactid integer = nothing     dim firstname string = ""     dim lastname string = ""     dim fullname string = ""     dim intwidth integer = nothing     dim textrendering size     dim cordx integer = 20     dim cordy integer = 30     dim runthrough integer= 0     dim tileline integer = 1     each row datarow in dtactive.rows         contactid = row(0)         firstname = row(1)         lastname = row(3)         fullname = firstname & " " & lastname         textrendering = textrenderer.measuretext(fullname, font)         intwidth = textrendering.width         dim newlabel new label()         newlabel             .parent = me             .text = fullname.tostring             .location = new point(cordx + 5, cordy + 5)             .name = "label" & contactid             .autosize = false             .size = new system.drawing.size(intwidth, 20)             me.groupbox1.controls.add(newlabel)         end         dim logonbtn new button         logonbtn             .parent = me             .location = new point(cordx, cordy)             .name = "tile" & contactid             .size = new system.drawing.size(140, 140)             .text = nothing             me.groupbox1.controls.add(logonbtn)             addhandler logonbtn.click, addressof loginout             try                 .backgroundimage = system.drawing.bitmap.fromfile(row(17).tostring) 'system.drawing.bitmap.fromfile(row(17).tostring)                 .backcolor = color.red                 .flatstyle = flatstyle.flat                 .backgroundimagelayout = imagelayout.zoom             catch ex exception             end try         end         cordx += 145          runthrough += 1 'this ensures once 3 buttons(tiles) have been made, next 3 on new line         if runthrough = 3             cordx = 20             cordy += 145             runthrough = 0         end if     next end sub 

this windows form: http://imageshack.us/photo/my-images/29/2bjm.jpg/

my idea going this: http://imageshack.us/photo/my-images/547/otuk.jpg/

winforms not have border control wpf does, going have draw border using graphicspath class.

here function draw rounded rectangle, need supply button's x,y coordinates, height/width , radius value rounded corners:

public sub drawroundrect(g graphics, p pen, x single, y single, width single, height single, radius single)     dim gp new graphicspath()      gp.addline(x + radius, y, x + width - (radius * 2), y) ' line     gp.addarc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90) ' corner     gp.addline(x + width, y + radius, x + width, y + height - (radius * 2)) ' line     gp.addarc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90) ' corner     gp.addline(x + width - (radius * 2), y + height, x + radius, y + height) ' line     gp.addarc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90) ' corner     gp.addline(x, y + height - (radius * 2), x, y + radius) ' line     gp.addarc(x, y, radius * 2, radius * 2, 180, 90) ' corner      gp.closefigure()      g.drawpath(p, gp)      gp.dispose() end sub 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -