 |
|
|
 |
|
 |
Hi All,
I am trying to create an owner drawn combo box(with image list instead of text) in individual cells of a Data Grid View.
Is this possible?
Can someone let me know how this is done or show some sample codes?
I would really appreacte it if someone could give some insights on how to do this.
Thanks
Rodzaidi
|
|
|
|
 |
|
 |
Does anyone knows the trick to draw the control like a push button when running under Vista?
|
|
|
|
 |
|
 |
Hi, thanks for the article, It was a great reference point for a particular problem I had: Populating a ComboBox with values from an enum, and having readable values appear in the ComboBox. Of course, there are a billion ways to do it, but using your technique is the most elegant I have seen thus far.
To share the love, here's the code I used. Nothing original, but someone might find it handy one day:
In the constructor:
__CmbBox.DataSource = Enum.GetValues(typeof(MyEnumeration));
__CmbBox.DrawMode = DrawMode.OwnerDrawFixed;
__CmbBox.DrawItem += new DrawItemEventHandler(UserDrawnComboBox_DrawItem);
Then, the event handler:
Thanks again!
|
|
|
|
 |
|
 |
Like many who use The Code Project we've spent countless hours building custom controls to meet our needs. Unfortunately, it's hard to justify spending thousands of hours on a custom control unless you intend to market them.
We've just released a beta of List Controls for .NET WinForms which includes the most advanced list box and combo box controls ever built for any platform.
Sounds too good to be true? Please, confirm this statement for yourself. A beta of List Controls is available for download from our website, including a comprehensive demo and tutorial.
http://www.it-partners.com/products/list_controls_win_forms/list_controls.asp[^]
Many features, too many to list here!
Brett Werner
it-partners.com
|
|
|
|
 |
|
 |
Hi,
Can we display colors in a combobox.... just like the color drop-down which is displayed in the properties of an object(Form, Button)
Thanks,
love nature
save nature
|
|
|
|
 |
|
 |
In the DrawItem event e.backGround : change it.
|
|
|
|
 |
|
 |
Hello,
I needed to have a simple combotree: items in a drop down list should be drawn tree alike. Here is a simple sample listing items depending on their Index value - the bigger the value, the further item is tabbed:
private void comboBox1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{
if (HierImageList == null)
return;
// define text and image location of an item listed in a drop-down portion
int textX = HierImageList.Images[e.Index].Width * (e.Index+1);
int imageX = HierImageList.Images[e.Index].Width * e.Index;
// define text and image location of a selected item item listed in an editable portion of a ComboBox.
if (comboBox1.RectangleToScreen(comboBox1.ClientRectangle).Contains(comboBox1.RectangleToScreen(e.Bounds)))
{
textX = HierImageList.Images[e.Index].Width;
imageX = e.Bounds.X;
}
e.Graphics.FillRectangle(new SolidBrush(e.BackColor), e.Bounds);
e.Graphics.DrawString(arr[e.Index], e.Font, new System.Drawing.SolidBrush(e.ForeColor),
new Point(textX, e.Bounds.Y));
e.Graphics.DrawImage(HierImageList.Images[e.Index], new Point(imageX, e.Bounds.Y));
}
regards,
Rimantas V.
|
|
|
|
 |
|
 |
Hi, I'm new in C# and started developing a userinterface as web application. I need combobox, and used dropdownlist. But I saw that Although existing of readonly property for dropdown, I couldn't write anything to its text. Finally I found that I must use combobox instead of dropdownlist.
Ok I did, I created a combobox at code behind page. I can see at design time but I couldn't show it on the web form.
Could someone help me o that issue. Thanks inadvance.
Selcan
------------------------------
using System.Windows.Forms;
NameSpace X
{
Public Class Y : System.Web.UI.Page
private ComboBox ComboBox1;
...
private void InitializeComponent()
{
this.ComboBox1 = new System.Windows.Forms.ComboBox();
this.ComboBox1.AccessibleName = "ComboBox1";
this.ComboBox1.AllowDrop = true;
this.ComboBox1.DataSource = this.DataSet11.PROVIDERS;
this.ComboBox1.DisplayMember = "name";
this.ComboBox1.Dock = System.Windows.Forms.DockStyle.Top;
this.ComboBox1.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.ComboBox1.ForeColor = System.Drawing.Color.Navy;
this.ComboBox1.Location = new System.Drawing.Point(17, 17);
this.ComboBox1.Name = "ComboBox1";
this.ComboBox1.Size = new System.Drawing.Size(121, 21);
this.ComboBox1.TabIndex = 0;
this.ComboBox1.ValueMember = "ID";
}
}
}
|
|
|
|
 |
|
 |
How to write a combo with each item is a check box item? Any idea?
Thanks.
|
|
|
|
 |
|
 |
Hi !
There is a class available solving your problem. Use instead of CComboBox CCheckComboBox. An example cou can find at
http://codeguru.earthweb.com/combobox/CheckedTree.html
Hope that helps you.
Bernie
|
|
|
|
 |
|
 |
I'm trying to draw a form in the place of the drawn object and I'm having trouble getting it to work. any thoughts?
|
|
|
|
 |
|
 |
You mean that you want to take the form and use it as a control? All you have to do is, well, turn it into a control.
It should work, but anything that requires form functionally will not work. For example, the keypreview option
|
|
|
|
 |
|
 |
I found an error behavior of combobox. When a combobox is placed in tabControl and I set the SelectedIndex to -1 indicating that the user has not made his choice yet, When the tabControl switch to other page and switch back to the page with the comboBox. The SelectedIndex will become 0 and no events of text-changed or selected-index-changed fired that caused my validating logic failed.
Do you know how to get around this problem?
|
|
|
|
 |
|
 |
Hi! I used your article to write my own owner draw ComboBox. The problem that I'm having is that I have bitmaps that are 32x32 and
I don't want to show them on the edit box (I
only show the text). The icons are higher than the text
so that I use the OnMeasureItem event, but I set the
ItemHeight property to the Font height so that the closed combo will
still look normal.
The problem in question is with the MaxDropDownItems property. I would
like to show a max number of items, but when I set the property, the
ComboBox calculates the number of items according to ItemHeight (which
is smaller than the actual height of the items), so it shows less
items in the drop list than I intended. Do you know of any way to set the drop down list size?
|
|
|
|
 |
|
 |
Works well. I just tweaked it so that it used system brushes rather than white for the background and it all works nicely. I'm also using an imagelist instead of loading the pics from disk at startup.
Anyway thanks again. This does just what I wanted with minimal effort on my part
|
|
|
|
 |
|
 |
I did the same too. Works well! Hats off Chanda!
|
|
|
|
 |
|
 |
Yes, great post. I combined it with URLCombobox (http://www.codeproject.com/cs/combobox/urlcombo.asp?target=urlcombobox) thus being able to create look/feel of a browser.
|
|
|
|
 |
|
 |
I tried it and the highlighting color does not appear when mouse hovering the item. DrawItemState.Focus seemed not working properly. The other thing was that the item got selected into the comboBox lost the picture, the font and the background.
Can you help?
BTW, I'm using the released version of VS.NET.
tedda
|
|
|
|
 |
|
 |
Exactly same thing happening to me, I am unable to see rest of items in the Combobox as well as the images.
|
|
|
|
 |
|
 |
Ok guys, I've just tried it on RC1 as well and it's working perfectly, I can change the fonts AND the highlight coloring as I wish. What images are you guys using by the way? Please either post your code here or email me directly and I'll have a look and see what I can do coz on my side the exact same code is working fine.
Regards
Senkwe
Just another wannabe code junky
|
|
|
|
 |
|
 |
Ok guys, I'll take the blame for this one for missing out an important step. You could have got there with a litle twaeking but anyways You have to make sure that your ComboBox has the DropDownStyle property set to DropDownList This makes sense in your case because you're experiencing a scenario where the chosen item is editable. You don't want this, so please change the property as above.
Regards
Senkwe
Just another wannabe code junky
|
|
|
|
 |
|
 |
Yes, my code works now. You learned know how to teach people tricks.
Good job, Senkwe. Looking forward to seeing more of your code here.
tedda
|
|
|
|
 |
|
 |
No problem
Thanks
Just another wannabe code junky
|
|
|
|
 |
|
 |
What if I don't want to DropDownStyle property set to DropDownList?
Is it possible to do the highlighting if you want to have a dropdown list, when the user can enter there own values, and still have the list highlight which item the mouse is over?
Thanks,
-Mike
(ya, I realize I'm over a year late on this thread...)
|
|
|
|
 |