0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Tips #009 ラジオボタンの選択によってカードの表示をコントロールしたい話

Posted at

ラジオボタンで「支払」を選択した場合のみ支払日のカードを表示させるように設定したい。

image.png

このような場合は「支払日」カードの詳細設定プロパティのVisibleでコントロールする。

image.png

初期値は
Visible = true

設定した値は以下のような感じ。

Visible = Switch(
    Radio1.Selected.Value,
    "支払", true,
    "請求", false
)

ラジオボタンで選択した値が"支払"の場合はVisible = true
"請求"の場合はVisible = falseになる。

IF文でも出来そうだけど個人的にはSwitchの方が好み。

ちなみにIF文の場合はこんな感じで動いた。

If(Radio1.Selected.Value="支払",true,false)

この場合は2択だったので"支払"じゃない場合はElseでFalseに出来るけど、
複数選択肢がある場合は、IFを入れ子にする必要があるのかなと。
興味がある方はやってみてください。

あ、肝心の動作結果貼り忘れた。

支払の場合は支払日が表示されて、
image.png

請求の場合は支払日が表示されません。
image.png

フォームの内容をリストに登録する際、ユーザーの入力項目によって
必須項目が可変になる場合に、このやり方を使うと不要な項目をユーザーに意識させる事がないので便利。

以上

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?