vb.net - A possibility of removing excessive code when dynamically creating objects? -
wanted know if there shorter way of writing i'm writing when dynamically creating form objects.
code below:
' margins & width buttons dim distancex integer = left + 20 dim distancey integer = 120 dim btnwidth integer = 120 ' initializing buttons removeundbtn = new button numbbtn = new button capsbtn = new button subsbtn = new button addtagsbtn = new button previewbtn = new button applybtn = new button cancelbtn = new button ' settings buttons removeundbtn .text = "remove underscore" .visible = true .enabled = false .top = distancey .width = btnwidth .left = distancex addhandler .click, addressof removeundaction end numbbtn .text = "number songs" .visible = true .enabled = false .top = removeundbtn.top + 22 .width = btnwidth .left = distancex addhandler .click, addressof numbaction end capsbtn .text = "capitalization" .visible = true .top = numbbtn.top + 22 .width = btnwidth .left = distancex addhandler .click, addressof capsaction end subsbtn .text = "substitution" .visible = true .enabled = false .top = capsbtn.top + 22 .width = btnwidth .left = distancex addhandler .click, addressof subsaction end addtagsbtn .text = "add tags" .visible = true .top = subsbtn.top + 22 .width = btnwidth .left = distancex addhandler .click, addressof addtagsaction end previewbtn .text = "preview" .visible = true .enabled = false .top = addtagsbtn.top + 44 .width = btnwidth .left = distancex addhandler .click, addressof previewaction end applybtn .text = "apply" .visible = true .top = previewbtn.top + 22 .width = btnwidth .left = distancex addhandler .click, addressof applyaction end cancelbtn .text = "cancel" .visible = true .top = applybtn.top + 22 .width = btnwidth .left = distancex addhandler .click, addressof cancelaction end ' adding buttons form me.controls.add(removeundbtn) me.controls.add(numbbtn) me.controls.add(capsbtn) me.controls.add(subsbtn) me.controls.add(addtagsbtn) me.controls.add(previewbtn) me.controls.add(applybtn) me.controls.add(cancelbtn) the buttons in above code created dynamically because indefinite number of objects not seen in above code created, expanding size of form.
tips on particular variables values i'm setting set default, making multiple monotonous lines 1 clean simple line. i'm looking for.
also, of buttons have enabled set false processes have not been completed.
Comments
Post a Comment