0
いくつかのフォームではコンボボックスを作成する重複したメソッドがあるプロジェクトで作業しています。以下のコードスニペットでは、特定のPCにインストールされているフォントがコンボボックスに項目として追加されています。どのように実際のコンボボックスを満たすためのパラメータを渡すことができますか?例えば、AddFonts(コンボボックス)パラメータとしてコントロールを渡す
Private Sub AddFonts()
'add the font names installed on this pc to the font name combo box
' Get the installed fonts collection.
Dim allFonts As New InstalledFontCollection
' Get an array of the system's font familiies.
Dim fontFamilies() As FontFamily = allFonts.Families
' Display the font families.
For i As Integer = 0 To fontFamilies.Length - 1
'figure our how to make the textbox passable as a paramter
cbxTitleFonts.Items.Add(fontFamilies(i).Name)
Next
End Sub
はい、私はDirectCastを使用しますが、パラメータは実際にどのように渡されますか?名前で – dinotom
?例えば、コンボボックスの名前がfooの場合、上の例ではmyfunc(foo)になりますか? – dinotom
ありがとうRomil下のコードは、AddFonts(Me.combobox)のようなサブメニューを呼び出すときの解決策です。 – dinotom