Controls

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Controls as PDF for free.

More details

  • Words: 1,493
  • Pages: 8
controls 1)button. private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click dim cek as new checkbox cek.size = new size(100, 20) cek.checkstate = checkstate.indeterminate cek.text = "checkbox1" cek.checked = true me.controls.add(cek) end sub private sub button2_click(byval sender as system.object, byval e as system.eventargs) handles button2.click dim pnl as new panel dim txt as new textbox dim label as new label pnl.location = new point(60, 20) pnl.size = new size(500, 500) dim cek1 as new checkbox cek1.size = new size(100, 20) cek1.text = "sss" me.controls.add(pnl) pnl.controls.add(cek1) 'pnl.controls.add(cek2) 'pnl.controls.add(cek3) end sub 2)‘runtime txt,rich txt, lbl,linklbl #region "runtime text box" private sub btntxt_click(byval sender as system.object, byval e as system.eventargs) handles btntxt.click dim txt as new textbox txt.size = new size(100, 200) txt.text = "hai elango" me.controls.add(txt) end sub #end region #region "runtime rich text box" private sub btnrichbox_click(byval sender as system.object, byval e as system.eventargs) handles btnrichbox.click dim richtxtbox as new richtextbox richtxtbox.size = new size(100, 100) richtxtbox.location = new point(20, 40) richtxtbox.text = "welcome" me.controls.add(richtxtbox) end sub #end region #region "runtime label box" private sub btnlbl_click(byval sender as system.object, byval e as

system.eventargs) handles btnlbl.click dim lblbox as new label lblbox.size = new size(200, 50) lblbox.location = new point(20, 150) lblbox.text = "new label box" me.controls.add(lblbox) end sub #end region #region "runtime linklabel box" private sub btnlnk_click(byval sender as system.object, byval e as system.eventargs) handles btnlnk.click dim lnklblbox as new linklabel lnklblbox.size = new size(200, 50) lnklblbox.location = new point(20, 200) lnklblbox.text = "new label box" me.controls.add(lnklblbox) end sub #end region private sub linklabel1_linkclicked(byval sender as system.object, byval e as system.windows.forms.linklabellinkclickedeventargs) handles linklabel1.linkclicked system.diagnostics.process.start("www.google.com") end sub 3) 'in this checked listbox,listbox,comboboxes,picture boxes are explianed #region "listbox" private sub btnlistbox_click(byval sender as system.object, byval e as system.eventargs) handles btnlistbox.click 'adding the items in listbox by using forloop dim item as integer for item = 1 to 10 listbox1.items.add("name" & item.tostring()) next end sub private sub lstbox1_selectedindexchanged(byval sender as system.object, byval e as system.eventargs) handles lstbox1.selectedindexchanged txtrichbox.text = lstbox1.selectedindex ''''it retrive the numerical value i.e position 'txtrichbox.text = lstbox1.selecteditem ''''it retrive the selected iitem 'txtrichbox.text = lstbox1.text end sub #end region #region "checkedlistbox" dim state as checkstate private sub txtchklstbox_click(byval sender as system.object, byval e as system.eventargs) handles txtchklstbox.click pnlchecklistbox.visible = true end sub private sub checkedlistbox1_itemcheck(byval sender as object, byval e as system.windows.forms.itemcheckeventargs) handles checkedlistbox1.itemcheck

state = checkedlistbox1.getitemcheckstate(0) ' dim newvalue as integer select case e.newvalue 'to select the checked value in the checkbox case checkstate.checked txtcheckedlistbox.text = "item" & e.index + 1 & "is checked " 'to select the unchecked value in the checkbox case checkstate.unchecked txtcheckedlistbox.text = "item" & e.index + 1 & " is unchecked" end select end sub #end region private sub commonfunction2_load(byval sender as system.object, byval e as system.eventargs) handles mybase.load statusbar1.panels.add("www") end sub end class 4) progressbar private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click timer1.enabled = true '''' after clicking the button1, the timer will be start(i.e timer region) and end when progress bar get its max value. after that timer will be disabled end sub #region "timer" private sub timer1_tick(byval sender as system.object, byval e as system.eventargs) handles timer1.tick progressbar1.value += 1 if progressbar1.value = progressbar1.maximum then timer1.enabled = false end if end sub #end region end class 5)trackbar private sub trackbar1_scroll(byval sender as system.object, byval e as system.eventargs) handles trackbar1.scroll textbox1.text = "the track bar value is:" & trackbar1.value end sub end class 6)date and time picker private sub datetimepicker1_valuechanged(byval sender as system.object, byval e as system.eventargs) handles datetimepicker1.valuechanged datetimepicker1.format = datetimepickerformat.custom 'datetimepicker1.customformat = "mmmm dd yyyy hh:mm:ss tt" 'datetimepicker1.customformat = "mmmm dd hh:mm:ss tt" 'datetimepicker1.customformat = "mmmm dd yyyy tt" datetimepicker1.customformat = "mm dd yy mm" ''''mm-denotes the month ''''mm-denotes the minitus

end sub private sub monthcalendar1_datechanged(byval sender as system.object, byval e as system.windows.forms.daterangeeventargs) handles monthcalendar1.datechanged 'textbox1.text = "day of the month selected: " & monthcalendar1.selectionrange.start.day '''' selectionrange contains 'start' and end' day 'textbox1.text = "day of the year selected: " & monthcalendar1.selectionstart.dayofyear ''''selectionstart contains 'day','month','year' 'textbox1.text = "day of the month selected: " & monthcalendar1.selectionstart.month textbox1.text = "day of the week selected: " & monthcalendar1.selectionstart.dayofweek end sub end class 7)timer dim balarm as boolean private sub timer1_tick(byval sender as system.object, byval e as system.eventargs) handles timer1.tick lbltimer.text = timeofday if txthour.text <> "" and txtmin.text <> "" and txtsec.text <> "" then dim alarm = new datetime(today.year, today.month, today.day, val(txthour.text), val(txtmin.text), val(txtsec.text)) if now >= alarm and balarm then beep() lbltimerevent.text = "alarm on" end if end if end sub private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click timer1.enabled = true end sub private sub rdotimer1_checkedchanged(byval sender as system.object, byval e as system.eventargs) handles rdotimer1.checkedchanged if rdotimer1.checked = true then balarm = true end if end sub private sub rdotimer2_checkedchanged(byval sender as system.object, byval e as system.eventargs) handles rdotimer2.checkedchanged if rdotimer2.checked = true then balarm = false end if end sub end class

8)tooltip & erroer provider private sub tooltipanderrorprovider_load(byval sender as system.object, byval e as system.eventargs) handles mybase.load tooltip1.settooltip(textbox1, "enetr the name") tooltip2.settooltip(textbox2, "enetr the password") end sub private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click if textbox1.text = "" then errorname.seterror(textbox1, "must enter name") end if if textbox2.text = "" then errorname.seterror(textbox2, "must enter pasword") end if end sub end class

9)tab page control

private sub panel1_paint(byval sender as system.object, byval e as system.windows.forms.painteventargs) handles panel1.paint tooltip1.settooltip(textbox1, "enter your name") tooltip2.settooltip(textbox2, "enter your password") end sub private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click if textbox1.text = "" then errorprovider1.seterror(textbox1, "you should enter your name") end if if textbox2.text = "" then errorprovider2.seterror(textbox2, "you should enter your password") end if end sub private sub button3_click(byval sender as system.object, byval e as system.eventargs) handles button3.click close() end sub private sub button4_click(byval sender as system.object, byval e as system.eventargs) handles button4.click close() end sub end class 10)treeview and list view private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click static index as integer = 0 if index < imagelist1.images.count - 1 then index += 1 else

index = 0 end if picturebox1.image = imagelist1.images(index) end sub private sub treeview1_afterselect(byval sender as system.object, byval e as system.windows.forms.treevieweventargs) handles treeview1.afterselect if e.node.checked = true then txttreeview.text = "you unchecked:" & e.node.text else

txttreeview.text = "you checked:" & e.node.text end if end sub private sub btn_click_click(byval sender as system.object, byval e as system.eventargs) handles btn_click.click 'treeview1.checkboxes = true end sub private sub image_click(byval sender as system.object, byval e as system.eventargs) handles image.click panelimage.visible = true end sub private sub treeview_click(byval sender as system.object, byval e as system.eventargs) handles treeview.click panelterrview.visible = true end sub end class 11)color dialogebox private sub btn_color_click(byval sender as system.object, byval e as system.eventargs) handles btn_color.click 'toolbox-color dialogclass 'if colordialog1.showdialog <> dialogresult.cancel then ' lbl_color.text = " this is new color" ' lbl_color.forecolor = colordialog1.color 'end if 'manual-color dialogclass dim color as new colordialog if (color.showdialog <> dialogresult.cancel) then lbl_color.text = "this is new color" lbl_color.forecolor = color.color end if end sub end class 12)font dialogbox private sub btn_display_click(byval sender as system.object, byval e as system.eventargs) handles btn_display.click 'toolbox-font dialogbox if fontdialog2.showdialog <> dialogresult.cancel then rich_font.font = fontdialog2.font rich_font.forecolor = fontdialog2.color end if 'font dialog through coding 'dim font as new fontdialog

'if (font.showdialog <> dialogresult.cancel) then ' rich_font.font = font.font ' rich_font.forecolor = font.color 'end if end sub end class 13)open file dialog box private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles btn_fileopen.click 'dim openfiledialog1 as new openfiledialog 'openfiledialog1.showdialog() 'if (openfiledialog1.showdialog) <> dialogresult.cancel then ' picturebox1.image = image.fromfile(openfiledialog1.filename) 'end if if (openfiledialog3.showdialog <> dialogresult.cancel) then picturebox1.image = image.fromfile(openfiledialog3.filename) end if end sub private sub btn_filesave_click(byval sender as system.object, byval e as system.eventargs) handles btn_filesave.click dim savefiledialog1 as new savefiledialog savefiledialog1.showdialog() if (savefiledialog1.showdialog <> dialogresult.cancel) then msgbox("you chose" & savefiledialog1.filename) end if end sub private sub openfiledialog3_fileok(byval sender as system.object, byval e as system.componentmodel.canceleventargs) handles openfiledialog3.fileok openfiledialog3.showhelp = true end sub end class

14)print dialog box

private sub printdialogclass_load(byval sender as system.object, byval e as system.eventargs) handles mybase.load richtextbox1.text = "on a new form drag a printdialog, printdocument,printpreviewcontrol, printpreviewdialog, pagesetupdialog, mainmenu and a richttextbox contol. select mainmenu and in the part, type file and under file type print, printpreview, pagesetup and ppcontrol. the menu should look like this:file->print, printpreview, pagesetup, ppcontrol. the richtextbox control is used to load some text in it which will be ready to print. the form in design view should look like the image below" end sub private sub menuitem2_click(byval sender as system.object, byval e as system.eventargs) handles menuitem2.click if printdialog1.showdialog <> dialogresult.cancel then printdocument1.printersettings = printdocument1.printersettings printdocument1.print()

end if end sub private sub menuitem3_click(byval sender as system.object, byval e as system.eventargs) handles menuitem3.click if printpreviewdialog1.showdialog <> dialogresult.ok then msgbox("pagesetup is correct") else msgbox("pagesetup is not correct") end if end sub private sub menuitem4_click(byval sender as system.object, byval e as system.eventargs) handles menuitem4.click with pagesetupdialog1 .pagesettings = printdocument1.defaultpagesettings end with if pagesetupdialog1.showdialog = dialogresult.ok then printdocument1.defaultpagesettings = pagesetupdialog1.pagesettings end if end sub end class

Related Documents

Controls
August 2019 42
Controls
November 2019 32
Controls
November 2019 32
Worksheet Controls
November 2019 12
Clutch Controls
October 2019 20