|
|
I have a custom ComboBox control that I am working on. I do all of the painting myself. When the DropDownStyle is "DropDownList", meaning there is no TextBox area, it displays perfectly. However, when in "Simple" or "DropDown" mode, the TextBox area has a black area under it about 6-8 pixels tall and the font of the TextBox is bold. Even if I take out ALL of my code in OnPaint and I leave "base.OnPaint" it does this.
If I remove "AllPaintingInWmPaint" and "UserPaint" from the call to "this.SetStyle" for the control, it displays correctly. Except the ComboBox itself is drawn with the Windows default. Only the drop-down items are painted with my custom drawing. How can I style the TextBox area of the ComboBox?
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|
|
As an alternative solution;
Take a Panel with the height of a TextBox . Put a TextBox on there, and position it on the left, leaving 23 dull pixels from the Panel visible.
You'd get something along these lines;
public partial class MyComboThingy : Panel
{
const int arrowLen = 23;
Panel dropDownPanel = new Panel();
bool open = false;
TextBox TextBoxValue = new TextBox();
public MyComboThingy()
{
this.MaximumSize = new Size(9999999, this.Height);
this.makeSmaller();
this.Controls.Add(TextBoxValue);
TextBoxValue.Location = new Point(0, 0);
makeSmaller();
Paint += this._Paint;
}
void makeSmaller()
{
TextBoxValue.Width = Width - arrowLen;
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
makeSmaller();
}
protected override void OnMouseClick(MouseEventArgs e)
{
base.OnMouseClick(e);
open = !open;
if (open)
{
dropDownPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
dropDownPanel.Parent = this.Parent;
dropDownPanel.BackColor = Color.White;
dropDownPanel.Location = new Point(
this.Location.X, this.Location.Y + this.Height);
dropDownPanel.Size = new Size(this.Width, 150);
dropDownPanel.BringToFront();
dropDownPanel.Show();
}
else
{
dropDownPanel.Hide();
}
}
private void _Paint(object sender, PaintEventArgs e)
{
Rectangle myRect = new Rectangle(
e.ClipRectangle.X + e.ClipRectangle.Width - arrowLen,
e.ClipRectangle.Y,
arrowLen,
e.ClipRectangle.Height);
try
{
ControlPaint.DrawComboButton(
e.Graphics,
myRect,
open ? ButtonState.Pushed : ButtonState.Normal);
}
catch
{ }
}
}
Bastard Programmer from Hell
|
|
|
|
|
Ah, okay, I appreciate it. I was hoping to simply extend the existing ComboBox but this looks simple as well. I am not too lazy to do it. I just did not want to go through that if it was simpler. :P Thanks.
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|
|
Is there a tool to keep track of user objects consumed by UI controls for a process ? I want to know the User objects/GDI objects consumed by different UI controls available within a single process. Please help.
|
|
|
|
|
Please don't crosspost. It's bad form.
|
|
|
|
|
Pete O'Hanlon wrote: Please don't crosspost. It's bad form.
Many newbies probably don't know what cross-posting means
|
|
|
|
|
Many don't seem to know what "How to get an answer to your question" means either.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I am generating a table.
each cell of that table has some information & an image.
now I want to assign a specific location to that image in each cell at runtime. please provide me necessary solution
|
|
|
|
|
Nope. I've tried to survey the mystic nugget of knowledge and it's just not giving up its secrets. Without its help, I just cannot work out which technology you are talking about. Is it ASP.NET, WPF, Silverlight, WinForms, Magic 8 Ball?
|
|
|
|
|
|
|
In future, when asking questions about ASP.NET, could you please use this[^] forum then? The quick answer to your question would be to use CSS to govern the positioning of the image - I assume you have got stylesheets in place for your web pages.
|
|
|
|
|
sir, I have to explain you the whole scenario.
I am actually generating barcodes.
Now each cell have some information related with a product along with it's barcode generated at runtime.
Now please tell me how can I place this barcode image at a specific position in a cell using coordinates & coding in c#.
|
|
|
|
|
Member 8374202 wrote: Now please tell me how can I place this barcode image at a specific position in
a cell using coordinates & coding in c#.
You can still use CSS for this. I suggest that you take this over to the ASP.NET forum now.
|
|
|
|
|
ok, sir
thank you for giving your time to me.
|
|
|
|
|
And a 5 from me for such a polite reply. Well done.
|
|
|
|
|
ok sir
I will get back to you if many problem related to c# will arrive
|
|
|
|
|
cells? it must be MineSweeper then. He probably wants to put up new bombs and different flags.
|
|
|
|
|
Hai
I developing a software in c# i want to know how to write code for cute comboboxes for windows7.
anyone can help me please ?
Arunkumar
|
|
|
|
|
What do you mean by cute comboboxes for windows7?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
which frontend tech. you are using (WPF, Silverlight , etc.)?
"Insanity is doing the same thing over and over again but expecting different results.” — Rita Mae Brown
|
|
|
|
|
iam using .net as my desktop application framework
|
|
|
|
|
That is a web site, so you need to look at the options available within ASP.NET for creating drop down lists. There are lots of articles here on CodeProject that will offer suggestions.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|