■5181 / ) |
Re[4]: ComboBoxでフォーカスのあるIDを取得するには? |
□投稿者/ とけい (4回)-(2007/07/06(Fri) 10:36:15)
|
魔界の仮面弁士さん偏し有難うございます。 お蔭様で期待していた通りに動作しました。 ありがとうございます。
一点追加で確認させて頂きたいのですが、 >「あまりスマートな方法では無いなぁ。(T_T)」と仰っておりますが 他に実現する方法はあるのでしょうか? もし宜しければ、キーワード等でも構いませんので勉強のために 教えてください。
宜しくお願いします。
■No5161 (魔界の仮面弁士 さん) に返信 > 2007/07/05(Thu) 19:03:57 編集(投稿者) > > ■No5159 (とけい さん) に返信 >>この場合のIndexIDを取得する方法は無いものでしょうか? > > とりあえず、番号をラベルに表示させてみました。 > > > // あまりスマートな方法では無いなぁ。(T_T) > private void Form1_Load(object sender, EventArgs e) > { > comboBox1.DrawMode = DrawMode.OwnerDrawFixed; > comboBox1.DrawItem += delegate(object combo, DrawItemEventArgs args) > { > if ((args.State & DrawItemState.Selected) == DrawItemState.Selected) > { > label1.Text = args.Index.ToString(); > } > args.DrawBackground(); > string itemText = String.Empty; > if (args.Index != -1) > { > ComboBox comboBox = (ComboBox)combo; > itemText = comboBox.GetItemText(comboBox.Items[args.Index]); > } > using (Brush brush = new SolidBrush(args.ForeColor)) > { > args.Graphics.DrawString(itemText, args.Font, brush, args.Bounds); > } > }; > }
|
|