1

特定のアイテムをカタログに追加するプログラムを作成しています。すべてのアイテムをライブラリ フォームからカタログ フォームに送信します。追加ボタンをクリックするたびに、新しいアイテムがカタログ形式で表示されます。また、各アイテムの詳細はArrayList NewItemに保存され、その結果静的クラスItemに追加されます。

すべてのアイテムはプログラムでCatalog formに追加されますが、新しいアイテムを追加するたびに以前のアイテムが上書きされるため、カタログ フォームは図のようになりますが、次のようになります。

ランボー1

ランボー1

ランボー2

何かアドバイス?

これは、新しいアイテムを追加するコードのサンプルです。

ArrayList hello = new ArrayList();

// NewItem is ArrayList into which all the item details are originally added

private void addItem(ArrayList NewItem)
{
    foreach (object obj in NewItem)
    {
        Item st = (Item)obj;
        String iname= st.IName.ToString();

        int helloe = hello.Count;
        for (int i = 0; i < helloe ; i++)
        {
            hello.Add(new Label());
            System.Drawing.Point p = 
                new System.Drawing.Point(35, 120+ helloe * 25);

            (hello[helloe] as Label).Location = p;
            (hello[helloe] as Label).Size = new System.Drawing.Size(80, 20);

            (hello[helloe] as Label).Text = iname.ToString();

            Catalouge.Controls.Add(hello[helloe] as Label);

サンプルフォーム

4

0 に答える 0