not one line of code... but a subroutine to do all textboxes. And you can make it global so it can be called from Any Form.
Add a new code module to your project. Add the following code to the module:
Public Sub SetTextBoxAlignment(ByRef TargetForm As Form, ByVal tbAlignment As Windows.Forms.HorizontalAlignment, Optional ByRef WatchForExceptions As Boolean = False) For Each ctlOnForm As Control In TargetForm.Controls If TypeOf ctlOnForm Is TextBox Then Dim tmpTB As TextBox = DirectCast(ctlOnForm, TextBox) If String.IsNullOrEmpty(tmpTB.Tag) Then tmpTB.TextAlign = tbAlignment Else If WatchForExceptions Then If Not tmpTB.Tag.ToString.StartsWith("x") Then tmpTB.TextAlign = tbAlignment End If Else tmpTB.TextAlign = tbAlignment End If End If End If Next End Sub
How to use the above Subroutine:
This will set the textbox alignment for the current form to center:
If you want to set the alignment for most of the textboxes but one or two, place an "x" in the Tag properties of those textboxes you which to exclude. Then use this line to set the alignment for all the textboxes except the ones you "Tagged".
SetTextBoxAlignment(Me, HorizontalAlignment.Center, True)
i want to thank you for your time to reply my post, i've tried out your code and it works like a charm =p
hi i am using vb.net multidimensional arrays and i am getting the nearest or closest number i just want to ask if my code was correct or not ? for example i have an input of 13000 and nearest number should be on col 6 can you please help me ...
I am developing a simple job card creator application with VB.net 2012, using Access 2010 as database.
The code I have generated to write data from a datagridview to the database table is successfully saving the data, but with an error "Parameter @name has no default value". The ...
write a C++ program which take inputs from the user/keyboard and calculate his ZAKAT.
get the input from user may include
-Amount invested in business
-Amount given to other business partners as loan
-Amount payable to others