0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Visual Studio / WPF > コントロール > TextBox > 改行許可 | タブ許可 | スクロールバーの表示

Last updated at Posted at 2017-04-27
動作環境
Windows 7 Pro (32bit)
Microsoft Visual Studio 2017 Community
Sublime Text 2

@ WPF 4.5入門 by 大田一希さん
No.5061 / 9985

4.10.1.1 改行やタブを受け入れるTextBoxコントロール

AcceptsReturnと AcceptsTabが紹介されている。
また、TextBoxにてスクロールバーを表示・非表示にするプロパティも紹介されている。
C++ BuilderのTMemoのスクロールバー付きに近いものができそうだ。

HorizontalScrollBarVisibilityとVerticalScrollBarVisibilityには以下の選択肢があるようだ。

  • Auto
  • Disabled
  • Visible
  • Hidden

Autoが気になったので使ってみた。

XAML
<Window x:Class="_170428_t0640_scroll.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:_170428_t0640_scroll"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="500">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="250"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <TextBox Grid.Column="0" 
                AcceptsReturn="True" AcceptsTab="True"
                 HorizontalScrollBarVisibility="Visible"
                 VerticalScrollBarVisibility="Visible"
                 Height="200" Width="200"/>
        <TextBox Grid.Column="1" 
                AcceptsReturn="True" AcceptsTab="True"
                 HorizontalScrollBarVisibility="Visible"
                 VerticalScrollBarVisibility="Auto"
                 Height="200" Width="200"/>
    </Grid>
</Window>

行が少ないとき
work.png

行が多いとき
work.png

右側のTextBoxにスクロールバーが付いた。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?