comboBox1_DrawItem......with icom

S

Supra

in vc.net...
private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
Bitmap bmp = new Bitmap(e.Bounds.Width,e.Bounds.Height,e.Graphics);
Graphics g = Graphics.FromImage(bmp);

g.FillRectangle(new SolidBrush(e.BackColor), new
Rectangle(0,0,bmp.Width,bmp.Height));
g.DrawString(comboBox1.Items[e.Index].ToString(),e.Font ,new
SolidBrush(e.ForeColor), new Point(28,(bmp.Height-e.Font.Height)/2));
g.DrawImage(imageList1.Images[e.Index], new Rectangle(new
Point(6,0),new Size(16,16)));
e.Graphics.DrawImage(bmp,e.Bounds.X,e.Bounds.Y);
}

convert to vb.net ................and i still got error problem for
drawstring and drawimage. i set drawmode to onwerdrawfixed and
dropdownstyle to dropdownlist

Private Sub comboBox1_DrawItem(ByVal sender As Object, ByVal e As
DrawItemEventArgs) Handles ComboBox1.DrawItem
Dim bmp As Bitmap = New
Bitmap(e.Bounds.Width,e.Bounds.Height,e.Graphics)
Dim g As Graphics = Graphics.FromImage(bmp)

g.FillRectangle(New SolidBrush(e.BackColor), New
Rectangle(0,0,bmp.Width,bmp.Height))
g.DrawString(comboBox1.Items(e.Index).ToString(),e.Font ,New
SolidBrush(e.ForeColor), New Point(28,(bmp.Height-e.Font.Height)/2))
g.DrawImage(imageList1.Images(e.Index), New Rectangle(New
Point(6,0),New Size(16,16)))
e.Graphics.DrawImage(bmp,e.Bounds.X,e.Bounds.Y)
End Sub

does ne 1 know how to fix problem?
regards,
supra
 
S

Supra

i got error problem........the error is:
Additional information: Specified argument was out of the range of valid
values.
g.DrawString(ComboBox2.Items(e.Index).ToString(), e.Font, New
SolidBrush(e.ForeColor), New PointF(28, (bmp.Height - e.Font.Height)/2))

i got icon working on dropdownlist but no text dispalying . does ne 1
knows how to get text displayed?
regards,
supra
i soloved problem by using pointF
regards
in vc.net...
private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
Bitmap bmp = new Bitmap(e.Bounds.Width,e.Bounds.Height,e.Graphics);
Graphics g = Graphics.FromImage(bmp);

g.FillRectangle(new SolidBrush(e.BackColor), new
Rectangle(0,0,bmp.Width,bmp.Height));
g.DrawString(comboBox1.Items[e.Index].ToString(),e.Font ,new
SolidBrush(e.ForeColor), new Point(28,(bmp.Height-e.Font.Height)/2));
g.DrawImage(imageList1.Images[e.Index], new Rectangle(new
Point(6,0),new Size(16,16)));
e.Graphics.DrawImage(bmp,e.Bounds.X,e.Bounds.Y);
}

convert to vb.net ................and i still got error problem for
drawstring and drawimage. i set drawmode to onwerdrawfixed and
dropdownstyle to dropdownlist

Private Sub comboBox1_DrawItem(ByVal sender As Object, ByVal e As
DrawItemEventArgs) Handles ComboBox1.DrawItem
Dim bmp As Bitmap = New
Bitmap(e.Bounds.Width,e.Bounds.Height,e.Graphics)
Dim g As Graphics = Graphics.FromImage(bmp)

g.FillRectangle(New SolidBrush(e.BackColor), New
Rectangle(0,0,bmp.Width,bmp.Height))
g.DrawString(comboBox1.Items(e.Index).ToString(),e.Font ,New
SolidBrush(e.ForeColor), New Point(28,(bmp.Height-e.Font.Height)/2))
g.DrawImage(imageList1.Images(e.Index), New Rectangle(New
Point(6,0),New Size(16,16)))
e.Graphics.DrawImage(bmp,e.Bounds.X,e.Bounds.Y)
End Sub

does ne 1 know how to fix problem?
regards,
supra
 
S

Supra

I solved again
thank alot

i got error problem........the error is:
Additional information: Specified argument was out of the range of
valid values.
g.DrawString(ComboBox2.Items(e.Index).ToString(), e.Font, New
SolidBrush(e.ForeColor), New PointF(28, (bmp.Height - e.Font.Height)/2))

i got icon working on dropdownlist but no text dispalying . does ne 1
knows how to get text displayed?
regards,
supra
i soloved problem by using pointF
regards
in vc.net...
private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
Bitmap bmp = new
Bitmap(e.Bounds.Width,e.Bounds.Height,e.Graphics);
Graphics g = Graphics.FromImage(bmp);

g.FillRectangle(new SolidBrush(e.BackColor), new
Rectangle(0,0,bmp.Width,bmp.Height));
g.DrawString(comboBox1.Items[e.Index].ToString(),e.Font ,new
SolidBrush(e.ForeColor), new Point(28,(bmp.Height-e.Font.Height)/2));
g.DrawImage(imageList1.Images[e.Index], new Rectangle(new
Point(6,0),new Size(16,16)));
e.Graphics.DrawImage(bmp,e.Bounds.X,e.Bounds.Y);
}

convert to vb.net ................and i still got error problem for
drawstring and drawimage. i set drawmode to onwerdrawfixed and
dropdownstyle to dropdownlist

Private Sub comboBox1_DrawItem(ByVal sender As Object, ByVal e As
DrawItemEventArgs) Handles ComboBox1.DrawItem
Dim bmp As Bitmap = New
Bitmap(e.Bounds.Width,e.Bounds.Height,e.Graphics)
Dim g As Graphics = Graphics.FromImage(bmp)

g.FillRectangle(New SolidBrush(e.BackColor), New
Rectangle(0,0,bmp.Width,bmp.Height))
g.DrawString(comboBox1.Items(e.Index).ToString(),e.Font ,New
SolidBrush(e.ForeColor), New Point(28,(bmp.Height-e.Font.Height)/2))
g.DrawImage(imageList1.Images(e.Index), New Rectangle(New
Point(6,0),New Size(16,16)))
e.Graphics.DrawImage(bmp,e.Bounds.X,e.Bounds.Y)
End Sub

does ne 1 know how to fix problem?
regards,
supra
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top