|
-
May 3rd, 2000, 03:53 PM
#1
Thread Starter
Hyperactive Member
Is it possible to change the FontNames of all Textboxes and
Labels (etc...) of all Forms (in VB3)?
For example: When the user clicks on a commdbutoon all
fonts in all forms change to 'Arial'
I would be very happy for some positive answers,
Matt-D(eutschland)
-
May 3rd, 2000, 04:20 PM
#2
transcendental analytic
You can go trough all controls in the form and chech if they have a fontname property. For each control in controls. I they have, change it. You can put on error resume next to avoid controls that don't have that property.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 3rd, 2000, 06:29 PM
#3
Frenzied Member
Something like
Code:
Dim objTemp as Object
For Each ObjTemp in Form1.Controls
On Error Resume Next
ObjTemp.FontName= "Arial"
On Error Goto 0
Next ObjTemp
-
May 3rd, 2000, 07:09 PM
#4
Lively Member
you can do this by using the forms and controls collection
Code:
Private Sub Edit_Controls()
Dim Y As Form
Dim X As Control
For Each Y In Forms
For Each X In Y.Controls
If (TypeOf X Is TextBox) Or (TypeOf X Is Label) Then
X.Font = "Arial"
X.Font.Bold = True
End If
Next X
Next Y
End Sub
however, this only works for loaded forms
MSDN says:
A Forms collection is a collection whose elements represent each loaded form in an application. The collection includes the application'sMDI form,MDI child forms, and non-MDI forms.
[Edited by Nina on 05-04-2000 at 03:29 PM]
-
May 3rd, 2000, 10:47 PM
#5
Thread Starter
Hyperactive Member
In VB3 it doesn't work.
BUT it alse tried it in VB4 and its prefect !
Soon I'll switch my program to VB 4
THX
[i] Matt-D(eutschland)
-
May 4th, 2000, 01:39 AM
#6
Member
Matt--
This should work in VB3
Sub renameControls(frm As Form)
Dim i As Integer
For i=0 to frm.Controls.Count - 1
If TypeOf frm.Controls(i) Is CheckBox Then
frm.Controls(i).FontName = "Arial"
ElseIf TypeOf frm.Controls(i) Is CommandButton Then
frm.Controls(i).FontName = "Arial"
ElseIf ...
...
End If
Next i
End Sub
In the Form_Load event of each form place the following code:
Call renameControls(Me)
You just have to make sure you've enumerated all the controls you've used. This will also work with custom controls.
viel Glück
--Carl
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|