次の方法で共有


テキスト ボックスを別のコントロールの前面または背面に移動する

次の使用例は、 TextBox の z オーダーを設定して、 ユーザーが TextBox 全体を表示できるように (これを z オーダーの前面に配置することによって)、または TextBox を他のコントロールの背後に配置できます (これを z オーダーの背面に送信します)。

この例を利用するには、次のコード例をフォームのスクリプト エディターにコピーします。 コードを実行するには、 Open イベントが生じるようにフォームを開く必要があります。 フォームには次のコントロールが含まれている必要があります。

  • 3 つのテキスト ボックス ( TextBox ) コントロール (TextBox1、TextBox2、および TextBox3)

  • トグル ボタン ( ToggleButton ) コントロール (ToggleButton1)

Dim ToggleButton1 
Dim TextBox1 
Dim TextBox2 
Dim TextBox3 
 
Sub Item_Open() 
Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").TextBox1 
Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").TextBox2 
Set TextBox3 = Item.GetInspector.ModifiedFormPages("P.2").TextBox3 
Set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").ToggleButton1 
 
'Set up text boxes to show z-order in the form 
TextBox1.Text = "TextBox 1" 
TextBox2.Text = "TextBox 2" 
TextBox3.Text = "TextBox 3" 
 
TextBox1.Height = 40 
TextBox2.Height = 40 
TextBox3.Height = 40 
 
TextBox1.Width = 60 
TextBox2.Width = 60 
TextBox3.Width = 60 
 
TextBox1.Left = 10 
TextBox1.Top = 10 
 
TextBox2.Left = 25 'Overlap TextBox2 on TextBox1 
TextBox2.Top = 25 
 
TextBox3.Left = 40 'Overlap TextBox3 on TextBox2, TextBox1 
TextBox3.Top = 40 
 
ToggleButton1.Value = False 
ToggleButton1.Caption = "Bring TextBox2 to Front" 
ToggleButton1.Left = 10 
ToggleButton1.Top = 90 
ToggleButton1.Width = 50 
ToggleButton1.Height = 50 
 
End Sub 
 
Sub ToggleButton1_Click() 
If ToggleButton1.Value = True Then 
 TextBox2.ZOrder (fmTop) 'Place TextBox2 on Top of z-order 
 
 'Update ToggleButton caption to identify next state 
 ToggleButton1.Caption = "Send TextBox2 to back" 
Else 
 TextBox2.ZOrder (1) 'Place TextBox2 on Bottom of z-order 
 
 'Update ToggleButton caption to identify next state 
 ToggleButton1.Caption = "Bring TextBox2 to front" 
End If 
End Sub

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。