|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Need equivalant code in VB.Net 2005 ?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. Show quoteHide quote "Luqman" <pearls***@cyber.net.pk> wrote in message news:uEs3eywJGHA.744@TK2MSFTNGP09.phx.gbl... > 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 > > > > Hi,
Try using the textbox's tag instead Ken --------------- Show quoteHide quote "Luqman" <pearls***@cyber.net.pk> wrote in message news:uEs3eywJGHA.744@TK2MSFTNGP09.phx.gbl... > 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 > > > > 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. -- Show quoteHide quoteAl Reid "Luqman" <pearls***@cyber.net.pk> wrote in message news:uEs3eywJGHA.744@TK2MSFTNGP09.phx.gbl... > 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 > > > > LuqMan
Have a look at databinding, that makes live a lot easier. http://www.vb-tips.com/default.aspx?ID=c4832a2a-2b95-4ded-93d9-4deb7fa4a0b8 I hope this helps, Cor |
|||||||||||||||||||||||