Need equivalant code in VB.Net 2005 ?

  • Thread starter Thread starter Luqman
  • Start date Start date
L

Luqman

In VB-6, I have put my field names in DataField Property of Textbox for Tag
Purpose.

In code, I use it as under:-

for each control in me.controls
if typeof control is textbox then
myrecordset.fields(control.datafield).value=control.text
endif
next

How can I use above code or similar in Vb.Net ?

Best Regards,

Luqman
 
My first guess is to inherit from the textbox and add your "datafield" to
it. Add a textbox to your form. Go into generated code (this differs between
2002 and 2005) and change "...As Textbox" to "...As MyTextBox." Voila.

Similar to your predicament, I missed the Tag property in Menus when I
started using VB.NET... luckily its easy to extend the functionality of any
control in .NET.
 
If you are not using the Tag property for anything else, use it to hold the field name. Also, as already mentioned, it's east to
extend the controls to add field name and table name, etc.
 
Back
Top