Rapide Et fasil: Chita la Taille de yon atik nan yon lis bwat nan yon App fenèt magazen an

Nan yon fenèt magazen App mwen menm ki kreye, M vle pou montre moun kap itilize li an plizyè informational mesaj mwen.  M pran yon ListBox kòm a konnen si yon moun pou montre l' lè sa a, yo ka faites par les Et tout bon bagay. 

Mesaj sont informational sèlman, Se konsa, pa gen okenn nesesite pou bay tout sa supplémentaires whitespace autour yo depi ke moun kap itilize li an pa janm ka chwazi yo pou anyen ankò.  Defo konpòtman de ListBox a bay yon montan importante de remplissage Et mwen te vle pou debarase li de sa.  byen.... ou pa kapab fè sa kalite bagay sou ListBox a tou dwat.  SEPANDAN, ou ka fè l' pou nou ajoute atik yo:

        pwive vid AddGameStateLogMessage(filè theMessage)
        {
            TextBox t = nouvo TextBox();
            t.Text = GameStateCounter     + ": " + theMessage;
            t.TextWrapping = TextWrapping.Wrap;
            t.MinWidth = 400;
            Pesè thisPadding = nouvo Pesè(5, 0, 5, 0);
            t.Padding = thisPadding;
            t.FontSize = 12;

            ListBoxItem li = nouvo ListBoxItem();
            li.Contenu = t;
            li.MaxHeight = 25;
            thisPadding = nouvo Pesè(5, 0, 5, 0);
            li.Marge = thisPadding;

            GameStateLog.Items.Insert(0,li);
        }

nan CI-dessus a, Mwen menm ki kreye yon TextBox Et mete li klavye, Marge li, ets.

Pwochen, Mwen kreye yon ListBoxItem Et définir contenu li pou tout en TextBox.

A la fen, Mwen mete an ListBoxItem nan ListBox la.  (Mwen vle montre mesaj ki pi resan nan tèt lis la, Insérez la(0,li) olye de yon senp Ajouter() invocation.).

Mwen pral fè réglages sa yon ti kras anvan mwen vwèman an jwa ak konpòtman ListBox men ki pa gen fòm montre pi wo pase trè fwitye.  Yon lòt moun twouve l' konsèy pou ede.

</fen>

undefinedVous pou m' blog.

Swiv mwen sou Twitter nan http://www.twitter.com/pagalvin

kite yon repons

Adrès imèl ou pa pral dwe pibliye. Jaden obligatwa yo make *