Formatting TextBoxes

  • Thread starter Thread starter Michael Turner
  • Start date Start date
M

Michael Turner

Hi Guys

I need to format multiple textboxes that are bound to a dataset, this
dataset can have its datachanged and refresh the data in the text boxes at
any time so I need a method that is quite flexable.

Mike.
 
Michael,

Just make an array of your textboxes and use that in a loop, it is very
simple.

You make the array as
\\\
dim textboxArray as Textbox() = New Textbox() {Textbox1, Textbox2, etc}
///
And than you can do everything you want with those textboxes in a loop. If
you want more samples, just reply for that.

I hope this helps?

Cor
 
Hi Cor

Thanks, it was the code to format the boxes that I was really after, can you
let me have an example.

Mike.
 
Michael,

I thought with format you did mean the width the height etc. Now I
understand you want an example from the format and parse event from the
datatables.

I have sand already this sample to this newsgroup however I make it more
complete in accoording to my previous message. I changed it in this message
so watch typos.

\\\\
Private Sub form_load etc.
dim textboxArray as Textbox() = New Textbox() {Textbox1, Textbox2, etc}
for i as integer = 0 to textboxArray.length - 1
myroutine(i)
end sub
next
Private Sub myroutine(byval box as integer)
Mybinding = New Binding("Text", ds.Tables(0), "mydatfield")
textboxArray(box).DataBindings.Add(Mybinding)
AddHandler mybinding.Format, AddressOf DBdateTextbox
AddHandler mybinding.Parse, AddressOf TextBoxDBdate
End sub
Private Sub DBdateTextbox(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
datum = CDate(cevent.Value)
cevent.Value = datum.ToString("dd - MM - yyyy")
End If
End Sub
Private Sub TextBoxDBdate(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value.ToString = "" Then
cevent.Value = DBNull.Value
End If
///

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top