Hi,
can you please tell me , how you get both text and image.
Quote:
Originally Posted by sajin
Thanks a ton to Morten and Moty....
It works fine. :-))
Regards
-Sajin
On May 21, 1:05 pm, Moty Michaely <Moty...@gmail.com> wrote:
> On May 21, 10:27 am, sajin <s...@iprlab.com> wrote:
>
>
>
>
>
> > Hi Morten,
>
> > I did as u said, but still i can't show image with text :-(
>
> > I added a imageList and added the images in that and assiciated with
> > combobox , where am i going wrong
> > using System;
> > using System.Collections.Generic;
> > using System.ComponentModel;
> > using System.Data;
> > using System.Drawing;
> > using System.Text;
> > using System.Windows.Forms;
>
> > namespace WindowsApplication1
> > {
> > public partial class Form1 : Form
> > {
> > public Form1()
> > {
> > InitializeComponent();
> > }
>
> > private void Form1_Load(object sender, EventArgs e)
> > {
> > string[] items;
>
> > items = new string[ComboBoxImageList.Images.Count];
>
> > for (int i = 0; i < ComboBoxImageList.Images.Count; i++)
> > {
> > this.comboBox1.Items.Add(ComboBoxImageList.Images[i]);
>
> > }
>
> > this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
> > this.comboBox1.DrawMode = DrawMode.OwnerDrawVariable;
> > this.comboBox1.ItemHeight =
> > this.ComboBoxImageList.ImageSize.Height;
> > this.comboBox1.Width =
> > this.ComboBoxImageList.ImageSize.Width + 80;
> > this.comboBox1.MaxDropDownItems =
> > this.ComboBoxImageList.Images.Count;
> > }
>
> > private void comboBox1_DrawItem(object sender,
> > DrawItemEventArgs e)
> > {
> > if (e.Index != -1)
> > {
>
> > e.Graphics.DrawImage(this.ComboBoxImageList.Images[e.Index],
> > e.Bounds.Left, e.Bounds.Top);
> > }
> > }
> > }
>
> > }
>
> > Regards
> > -Sajin
>
> > On May 18, 9:45 pm, "Morten Wennevik [C# MVP]"
>
> > <MortenWenne...@hotmail.com> wrote:
> > > Hi Sajin,
>
> > > You need to specify DrawMode. OwnerDrawFixed is usually good enough, but use OwnerDrawVariable if the height of the items can vary.
>
> > > Set DropDownStyle to DropDownList to be able to draw the selected item in the EditBox
>
> > > Then subscribe to the ComboBox' DrawItem event. It will be called for each item in the list. Use the DrawItemEventArgs to find out what kind of item you are currently drawing and use DrawItemEventArgs.Bounds to position your drawing. You can then draw image and text any way you like. DrawItemEventArgs.State has information of wether the current item is highligted and so on.
>
> > > If you need more specific information, please ask.
>
> > > On Fri, 18 May 2007 09:12:50 +0200, sajin <s...@iprlab.com> wrote:
> > > > Hi All,
>
> > > > I am new to windows forms C# 2005, How can i have a combo box with
> > > > image and text
>
> > > > meaning
>
> > > > * 1Star
> > > > ** 2Start
> > > > *** 3Star
>
> > > > i have experimented something. but it shows only images.
>
> > > > Any help will be appreciated
>
> > > > Regards
> > > > -Sajin
>
> > > --
> > > Happy coding!
> > > Morten Wennevik [C# MVP]- Hide quoted text -
>
> > > - Show quoted text -
>
> Sajin
>
> I can't see where the text of an item is added? You are adding an
> Image item to the combo box items list.
> I think that Morten suggested to draw both the image and the text
> (using DrawText()).
>
> Therfore, the item added to the list should contain information about
> both the image and the text to be displayed. Maybe you can use a
> wrapper class to hold the item information.
>
> Feel free to ask any question regarding the custom drawing issue.
>
> Moty- Hide quoted text -
>
> - Show quoted text -
|