|
Sorry for my simple example. Yes, I am passing the PaintEventArgs that is passed to the event. So the GC is being used to do all the painting.
--Ian;
|
|
|
|
|
That's why we always suggest Copy-'n-Paste the code instead of retyping it.
You said that this text is being painted OVER what your code painted?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I'm painting the background a green with a FillRectangle, and when it is displayed to the screen, I see a 2 or 3 pixel border of green surrounding a black text box region (that was not drawn by me). This is what I mean when I say that it was drawn over top of what I had drawn.
The sample class below does not contain all the code, however it will give you an idea of the problem. Just drop this class into your a project, compile, and drop it the ComboDraw control onto a form.
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace ComboTest<br />
{<br />
class ComboDraw : ComboBox<br />
{<br />
public ComboDraw()<br />
{<br />
DrawMode = DrawMode.OwnerDrawFixed;<br />
DropDownStyle = ComboBoxStyle.DropDown;<br />
FlatStyle = FlatStyle.Flat;<br />
SetStyle(ControlStyles.UserPaint, true);<br />
}<br />
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
base.OnPaint(e);<br />
<br />
e.Graphics.FillRectangle(new SolidBrush(Color.Green), ClientRectangle);<br />
}<br />
}<br />
}<br />
--Ian;
-- modified at 9:19 Thursday 13th July, 2006
|
|
|
|
|
OK. I see what you're looking at.
You're seeing the TextBox being drawn by the underlying ComboBox class. The bad news is, as far as I can tell, you can't get rid of it and can't override it. It's completely hidden behind "private" everything.
I've also never had to custom draw the entire Combobox. I've only done the drop down list and that turned out to be pretty easy.
Why are you trying to custom paint the entire thing?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Why? I ask myself that question all the time. The answer is the same old story of having all controls behave consistently to the color scheme that has been chosen. Sometimes you can't choose your battles, you just have to fight. I have a few more hacks to try in the meantime.
--Ian;
|
|
|
|
|
I have no idea how to get past this one. If it wasn't such a PITA composite control, it'd be real easy!
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
How can add a dropdown button in a Windows Application?
Regards,
Wasif Ehsan.
|
|
|
|
|
What do you mean by a dropdown button?
---
b { font-weight: normal; }
|
|
|
|
|
A dropdown button is a normal button with a separate section on the right (or left) side with an arrow image. When you click on the arrow, a little dropdown container pops open. The container can provide other options related to action performed by clicking the button.
:josh:
My WPF Blog[^]
|
|
|
|
|
The Infragistics NetAdvantage suite has the UltraDropDownButton control. Other than that, there's no dropdown button control in WinForms that I know of.
:josh:
My WPF Blog[^]
|
|
|
|
|
I am using Microsoft visual studio 2005
Now Bussiness objects provide 3 different kinds of merge modules....
1-> Crystal Report for .Net Framework 2.0 x86 Redistributable package(32 bit)
2-> Crystal Report for .Net Framework 2.0 IA 64 Redistributable package(64 bit)
3-> Crystal Report for .Net Framework 2.0 x64 Redistributable package(64 bit)
Now i am not able to figure out which modules will suite my application.
Can any one help me in figuring it out.
How to find wheather my .net framework is x86 (or) IA 64 (or) x64.
Thank U.
Jats
|
|
|
|
|
Hi,
I am hosting a browser control(framework 2.0) in a form of fixed size. Control is docked as fill in the win form.
The control navigates to some url and displays the web page. Now if the web page size exceeds the win form size scrollbars appears.
I want to calculate the complete height and width of control(complete scrollable height and width). Let me know how i can do it.
Note that i can do it using the HTMLDocument's scrollheight and scrollwidth properties but the problem is it returns correct values only when the height and width are specified. Correct values are not guaranteed through it.
Thanks,
Yash
|
|
|
|
|
Why can’t we use Exception class for handling all exceptions. Why do we use specific calsses like Arithmetic Exception, IOException etc...
Thanks
Simha
simha
|
|
|
|
|
...you can like this (C#):
try
{
}
catch (Exception ex)
{
}
But all you get is a signal if anything fails. By using different exception types, you can perform different actions when failure occurs.
try
{
}
catch (ArgumentException ex)
{
}
catch (IOException ex)
{
}
Regards,
Rob Philpott
|
|
|
|
|
You should however have a blanket catcher at the end of your highest level catch blocks to do a clean shutdown when an unanticipated error occured because the app could've ended up in an incoherant state.
|
|
|
|
|
This works because all the other exceptions inherit from System.Exception (although, not directly). A child exception should be listed before its parent in a list like above. Lets say I made two custom exceptions:
BadDataException
and
BadIntegerException : BadDataException
A BadInteger is a specific kind of BadData so I have it inheriting from BadData. This means I have to option of catching any BadData and doing something or:
<br />
catch (BadIntegerException)<br />
{<br />
}<br />
catch (BadDataException)<br />
{<br />
}<br />
which would do something if it were an integer, but something else if it were a different kind of bad data.
This:
<br />
catch (BadDataException)<br />
{<br />
}<br />
catch (BadIntegerException)<br />
{<br />
}<br />
Is bad because an BadIntegerExceptions that get thrown will be caught by the first catch and the code in the second block will never get executed.
|
|
|
|
|
It does make sense to me that it would, but when I have multiple assemblies that examine the (TraceLevelSwitch), which is configure for a different value in each assembly. However, they all seem to operate on the same value, rather than the one configured in the individual .config files.
Detail:
Assembly A - .dll
Assembly B - .dll
Assembly C - windows forms app .exe
All assemblies use the following code:
private static System.Diagnostics.TraceSwitch _TraceLevelSwitch = new System.Diagnostics.TraceSwitch("TraceLevelSwitch", "Tracing level");
All assemblies seem to pick up the value for Assembly C, which runs/loads first.
Anyone got some insight into this?
|
|
|
|
|
.DLL's can't have their own config files. They'll always use the .EXE's config in which their running.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I was afraid of that.
Perhaps I could use different explicit switches in the main app's .config?
Thanks for the reply.
|
|
|
|
|
The configuration is on the AppDomain level. If you're bonkers enough you can create a new appdomain, set its base directory/config file path etc, load your satellite assemblies in to that, and call them dynamically, but its a rubbish idea and I wish I'd never said anything now.
Regards,
Rob Philpott.
|
|
|
|
|
No Worries.
By constructing the key (value) name at run-time, based on the assembly name, I can control the behavior of each assembly individually from one .config file, which is a better solution anyway.
Thanks for the info.
|
|
|
|
|
|
My application needs to detect the insertion of a USB memory stick and get the device path of it.
I've wrote:
/* treat lParam a pointer to a standard structure DEV_BROADCAST_HDR */
lpdb = (PDEV_BROADCAST_HDR)lParam;
/* check the type */
if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME)
{
But I'm not sure if USB mass storage class is DBT_DEVTYP_VOLUME or DBT_DEVTYP_DEVICEINTERFACE.
Anyone, please help me.
|
|
|
|
|
I am writing a client application that will have its own database, all the modifications takes place in that database. I want to synchronize this database with the main database residing on Server machine.
I am using SQL Server Database.
I'm struggling to find anywhere some recommended techniques for synchronizing two databases.
Can somebody send me some links that discusses some of these ideas in detail?
Thanks
.Net Programmer, Software Engineer
|
|
|
|
|
Check out these guys:
Red Gate
Unfortunately, I have not found any free solutions. However, Red Gate is 250-500$ where others are 25,000$-50,000$.
If anyone knows of any good SQL Comparision tools for FREE please post those links here!!!!
Fred
fred[at]eastpointsystems.com
|
|
|
|