0

Visual Studio Compact Framework 3.5 C# で GUI 要素 (フィールド ボックス、ボタン、ラベルなど) を非表示にして再配置する最良の方法は何ですか?

フィールドとラベルの非表示を実装しようとしましたが、現時点では非常に面倒なプロセスのようです (改善できるかどうかはわかりません)。私がそれを行う方法の例は、以下のコードにあります...

ご覧のとおり、かなり乱雑になる可能性があります。私がそこで行っているのは、最初にブール制御配列を生成し、その配列を使用して、最初に指定されたフィールドを非表示にしてから、すべてを上に移動して空のスペースを削除することです。これを行うためのより良い方法を見つけようとしています。

また、これらの GUI 要素の配置を制御できる方法を探しています。FirstName フィールドではなく、LastName フィールドを最初に表示させたいとしましょう。この形式でコードを書き直さなくても、どうすればそれを行うことができますか?

// Generate boolean array to control visible status of each field
bool[] hideControl = new bool[13];
for (int i = 0; i <= 12; i++)
{
   hideControl[i] = Convert.ToBoolean(MobileConfiguration.Settings[i]);
}
// Difference in pixels between two input panels
int diff = this.txtLastName.Location.Y - this.txtFirstName.Location.Y;
// Hide Fields
hideFields(hideControl);

// Movie Fields
moveFields(hideControl, diff);
..................
// hideFields function
if (hideValue[0] == true)
{
    // Hide Install
    this.txtFirstName.Visible = false;
    this.lblFirstName.Visible = false;
}
// And so forth for each 12 fields
...................
// moveFields function
if (hideValue[0] == true)
{
    // LastName -- 2nd field
       this.txtLastName.Location = new Point(this.txtLastName.Location.X, (this.txtLastName.Location.Y - diff));
    this.lblLastName.Location = new Point(this.lblLastName.Location.X, (this.lblLastName.Location.Y - diff));
    // So forth for 11 fields
}
if (hideValue[1] == true)
{
    // Move up other 10 fields
}
if (hideValue[2] == true)
{
    // Move up other 9 fields
}

そのフォームの私のGUIは次のようになります(ラベルとテキストボックスが1行に表示されます):

PanelName1

FirstName ______
LastName _______
Addresss _______
....etc
4

1 に答える 1