comboBox1_DrawItem......with icom

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Supra

    comboBox1_DrawItem......with icom

    in vc.net...
    private void comboBox1_DrawI tem(object sender, DrawItemEventAr gs e)
    {
    Bitmap bmp = new Bitmap(e.Bounds .Width,e.Bounds .Height,e.Graph ics);
    Graphics g = Graphics.FromIm age(bmp);

    g.FillRectangle (new SolidBrush(e.Ba ckColor), new
    Rectangle(0,0,b mp.Width,bmp.He ight));
    g.DrawString(co mboBox1.Items[e.Index].ToString(),e.F ont ,new
    SolidBrush(e.Fo reColor), new Point(28,(bmp.H eight-e.Font.Height)/2));
    g.DrawImage(ima geList1.Images[e.Index], new Rectangle(new
    Point(6,0),new Size(16,16)));
    e.Graphics.Draw Image(bmp,e.Bou nds.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_DrawI tem(ByVal sender As Object, ByVal e As
    DrawItemEventAr gs) Handles ComboBox1.DrawI tem
    Dim bmp As Bitmap = New
    Bitmap(e.Bounds .Width,e.Bounds .Height,e.Graph ics)
    Dim g As Graphics = Graphics.FromIm age(bmp)

    g.FillRectangle (New SolidBrush(e.Ba ckColor), New
    Rectangle(0,0,b mp.Width,bmp.He ight))
    g.DrawString(co mboBox1.Items(e .Index).ToStrin g(),e.Font ,New
    SolidBrush(e.Fo reColor), New Point(28,(bmp.H eight-e.Font.Height)/2))
    g.DrawImage(ima geList1.Images( e.Index), New Rectangle(New
    Point(6,0),New Size(16,16)))
    e.Graphics.Draw Image(bmp,e.Bou nds.X,e.Bounds. Y)
    End Sub

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


  • Supra

    #2
    Re: comboBox1_DrawI tem......with icom

    i soloved problem by using pointF
    regards

    Supra wrote:
    [color=blue]
    > in vc.net...
    > private void comboBox1_DrawI tem(object sender, DrawItemEventAr gs e)
    > {
    > Bitmap bmp = new Bitmap(e.Bounds .Width,e.Bounds .Height,e.Graph ics);
    > Graphics g = Graphics.FromIm age(bmp);
    >
    > g.FillRectangle (new SolidBrush(e.Ba ckColor), new
    > Rectangle(0,0,b mp.Width,bmp.He ight));
    > g.DrawString(co mboBox1.Items[e.Index].ToString(),e.F ont ,new
    > SolidBrush(e.Fo reColor), new Point(28,(bmp.H eight-e.Font.Height)/2));
    > g.DrawImage(ima geList1.Images[e.Index], new Rectangle(new
    > Point(6,0),new Size(16,16)));
    > e.Graphics.Draw Image(bmp,e.Bou nds.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_DrawI tem(ByVal sender As Object, ByVal e As
    > DrawItemEventAr gs) Handles ComboBox1.DrawI tem
    > Dim bmp As Bitmap = New
    > Bitmap(e.Bounds .Width,e.Bounds .Height,e.Graph ics)
    > Dim g As Graphics = Graphics.FromIm age(bmp)
    >
    > g.FillRectangle (New SolidBrush(e.Ba ckColor), New
    > Rectangle(0,0,b mp.Width,bmp.He ight))
    > g.DrawString(co mboBox1.Items(e .Index).ToStrin g(),e.Font ,New
    > SolidBrush(e.Fo reColor), New Point(28,(bmp.H eight-e.Font.Height)/2))
    > g.DrawImage(ima geList1.Images( e.Index), New Rectangle(New
    > Point(6,0),New Size(16,16)))
    > e.Graphics.Draw Image(bmp,e.Bou nds.X,e.Bounds. Y)
    > End Sub
    >
    > does ne 1 know how to fix problem?
    > regards,
    > supra
    >
    >[/color]

    Comment

    • Supra

      #3
      what does that mean........... ..

      i got error problem........ the error is:
      Additional information: Specified argument was out of the range of valid
      values.
      g.DrawString(Co mboBox2.Items(e .Index).ToStrin g(), e.Font, New
      SolidBrush(e.Fo reColor), 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

      Supra wrote:
      [color=blue]
      > i soloved problem by using pointF
      > regards
      >
      > Supra wrote:
      >[color=green]
      >> in vc.net...
      >> private void comboBox1_DrawI tem(object sender, DrawItemEventAr gs e)
      >> {
      >> Bitmap bmp = new Bitmap(e.Bounds .Width,e.Bounds .Height,e.Graph ics);
      >> Graphics g = Graphics.FromIm age(bmp);
      >>
      >> g.FillRectangle (new SolidBrush(e.Ba ckColor), new
      >> Rectangle(0,0,b mp.Width,bmp.He ight));
      >> g.DrawString(co mboBox1.Items[e.Index].ToString(),e.F ont ,new
      >> SolidBrush(e.Fo reColor), new Point(28,(bmp.H eight-e.Font.Height)/2));
      >> g.DrawImage(ima geList1.Images[e.Index], new Rectangle(new
      >> Point(6,0),new Size(16,16)));
      >> e.Graphics.Draw Image(bmp,e.Bou nds.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_DrawI tem(ByVal sender As Object, ByVal e As
      >> DrawItemEventAr gs) Handles ComboBox1.DrawI tem
      >> Dim bmp As Bitmap = New
      >> Bitmap(e.Bounds .Width,e.Bounds .Height,e.Graph ics)
      >> Dim g As Graphics = Graphics.FromIm age(bmp)
      >>
      >> g.FillRectangle (New SolidBrush(e.Ba ckColor), New
      >> Rectangle(0,0,b mp.Width,bmp.He ight))
      >> g.DrawString(co mboBox1.Items(e .Index).ToStrin g(),e.Font ,New
      >> SolidBrush(e.Fo reColor), New Point(28,(bmp.H eight-e.Font.Height)/2))
      >> g.DrawImage(ima geList1.Images( e.Index), New Rectangle(New
      >> Point(6,0),New Size(16,16)))
      >> e.Graphics.Draw Image(bmp,e.Bou nds.X,e.Bounds. Y)
      >> End Sub
      >>
      >> does ne 1 know how to fix problem?
      >> regards,
      >> supra
      >>
      >>[/color]
      >[/color]

      Comment

      • Supra

        #4
        never mind...........

        I solved again
        thank alot


        Supra wrote:
        [color=blue]
        > i got error problem........ the error is:
        > Additional information: Specified argument was out of the range of
        > valid values.
        > g.DrawString(Co mboBox2.Items(e .Index).ToStrin g(), e.Font, New
        > SolidBrush(e.Fo reColor), 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
        >
        > Supra wrote:
        >[color=green]
        >> i soloved problem by using pointF
        >> regards
        >>
        >> Supra wrote:
        >>[color=darkred]
        >>> in vc.net...
        >>> private void comboBox1_DrawI tem(object sender, DrawItemEventAr gs e)
        >>> {
        >>> Bitmap bmp = new
        >>> Bitmap(e.Bounds .Width,e.Bounds .Height,e.Graph ics);
        >>> Graphics g = Graphics.FromIm age(bmp);
        >>>
        >>> g.FillRectangle (new SolidBrush(e.Ba ckColor), new
        >>> Rectangle(0,0,b mp.Width,bmp.He ight));
        >>> g.DrawString(co mboBox1.Items[e.Index].ToString(),e.F ont ,new
        >>> SolidBrush(e.Fo reColor), new Point(28,(bmp.H eight-e.Font.Height)/2));
        >>> g.DrawImage(ima geList1.Images[e.Index], new Rectangle(new
        >>> Point(6,0),new Size(16,16)));
        >>> e.Graphics.Draw Image(bmp,e.Bou nds.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_DrawI tem(ByVal sender As Object, ByVal e As
        >>> DrawItemEventAr gs) Handles ComboBox1.DrawI tem
        >>> Dim bmp As Bitmap = New
        >>> Bitmap(e.Bounds .Width,e.Bounds .Height,e.Graph ics)
        >>> Dim g As Graphics = Graphics.FromIm age(bmp)
        >>>
        >>> g.FillRectangle (New SolidBrush(e.Ba ckColor), New
        >>> Rectangle(0,0,b mp.Width,bmp.He ight))
        >>> g.DrawString(co mboBox1.Items(e .Index).ToStrin g(),e.Font ,New
        >>> SolidBrush(e.Fo reColor), New Point(28,(bmp.H eight-e.Font.Height)/2))
        >>> g.DrawImage(ima geList1.Images( e.Index), New Rectangle(New
        >>> Point(6,0),New Size(16,16)))
        >>> e.Graphics.Draw Image(bmp,e.Bou nds.X,e.Bounds. Y)
        >>> End Sub
        >>>
        >>> does ne 1 know how to fix problem?
        >>> regards,
        >>> supra
        >>>
        >>>[/color]
        >>[/color]
        >[/color]

        Comment

        Working...