下記のようにオーナードローを行いたいのですが
DataSourceにデータセットを設定している為
連結されているText値を取得できません。
(System.Data.DataRowViewと表示されてしまう)
ItemにAddで項目を追加すればうまく行くのですが
出来ればデータセットを使用したいです。
どのようにすれば値を取得できるのでしょうか?
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
ListBox1.DrawMode = DrawMode.OwnerDrawFixed
End Sub
Private Sub ListBox1_DrawItem1(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DrawItemEventArgs) _
Handles ListBox1.DrawItem
e.DrawBackground()
'↓--------描画する文字列の取得がうまく行かない
Dim txt As String = CType(sender, ListBox).Items(e.Index).ToString()
e.Graphics.DrawString(txt, e.Font, b, e.Bounds.X, e.Bounds.Y)
b.Dispose()
e.DrawFocusRectangle()
End Sub
ComboBox CB = ((ComboBox) sender);
System.Data.DataRowView DV = (System.Data.DataRowView)CB.Items[e.Index];
string txt = DV[1].ToString();
ツイート | ![]() |