vb.net - Check for empty text boxes when using lists -


i have following code:

private sub editartoolstripmenuitem_click(sender object, e eventargs) handles editartoolstripmenuitem.click         dim ctleditable = {txtcodigo, txtdeudor, txtoportunidad, drpbanca, txtejecutivo, drpgarantia, txtciiu, dtefecha, txtanalista, drpestatus, drpconcepto, dteultact, txtingresos, drpcumplimiento, txtroa2, txtie2, txtant, txtact, txtcovenants, drpfaltas, txtoportunidades, txtcostos, txtpmaa}.tolist()         dim ctltext = {txtcodigo, txtdeudor, txtoportunidad, drpbanca, txtejecutivo, drpgarantia, txtciiu, dtefecha, txtanalista, drpestatus, drpconcepto, dteultact, txtingresos, drpcumplimiento, txtroa2, txtie2, txtant, txtact, txtcovenants, drpfaltas, txtoportunidades, txtcostos, txtpmaa}.tolist()         dim ctlperma = {txtras, txtactividad, txttipo, txtmultapot, txtpotencial}.tolist()         dim control control         each control in me.controls             if typeof (control) textbox                 dim txtbox textbox = control                 if txtbox.text.length = 0                     ctleditable.foreach(sub(c) c.enabled = false)                 else                     ctleditable.foreach(sub(c) c.enabled = true)                     return                 end if             end if         next     end sub 

i'm trying check if text boxes empty before enabling them edit; if they're empty can't edit, if there's text can. tried answer in: check empty textbox controls in vb.net didn't work.

any ideas?

what should work out whether or not enable them , execute foreach loop enable / disable.

    dim enable = me.controls.oftype(of textbox).any(function(t) t.text.length > 0)     ctleditable.foreach(sub(c) c.enabled = enable) 

however suspect you'll want use ctleditable instead of me.controls me.controls contains top level controls of form.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -