In fact the BackColor of control doesn't change and only ForeColor and BorderColor change. Set FlatStyle to Flat, Set a non system BorderColor in FlatAppearance, Set a non system BackColor and you will see background and border will not change. Only ForeColor changes to show difference of enabled and disabled button.
xstoneheartx
Posts
-
How to avoid color changes when button is disabled -
Looking for C# winforms control / library to manage different map-based plain image layersLong time ago, I made an application near to your requirements. The main design was:
- An abstract base Shape class having some methods like a void Render(Graphics) and a method for hit testing,bool HitTest(Point).
- Shape classes for custom shapes that are needed on each layer; shapes like point, line, icon, path, etc that inherit from abstract Shape class.
- Each derived shape has its own properties and overrides Render method and renders itself on the graphics object; also overrides HitTest method to check if it contains a point.
- A Layer class that contains a List of Shapes and a void Render(Graphics) and calls render method of each shape. (You can restrict each layer to specific types of shapes, you can implement z-order management for shapes, etc)
- A Map class having and Image and a List<Shapes> and Save and Load to/from file. (You can handle Active layer and active shape easily.)
- A custom control that has a Map property. This control is responsible for rendering layers and handling user mouse interaction and update layers. This control overrides OnPaint and mouse events and enables double buffering.
Hope this idea helps you.
-
rdlc report in c# winforms programmaticallyProbably the name of dataset in your Report is different than "Employee". Open your report and in "Report Data" window, under the node "Datasets", check the name of your dataset, for example if dataset name is "Dataset1", your code should be:
Microsoft.Reporting.WinForms.ReportDataSource repds = new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", ds.Tables[0]);
-
how to disable windows form hide animation?Maybe this help:
enum DWMWINDOWATTRIBUTE : uint
{
NCRenderingEnabled = 1,
NCRenderingPolicy,
TransitionsForceDisabled,
AllowNCPaint,
CaptionButtonBounds,
NonClientRtlLayout,
ForceIconicRepresentation,
Flip3DPolicy,
ExtendedFrameBounds,
HasIconicBitmap,
DisallowPeek,
ExceludedFromPeek,
Cloak,
Cloaked,
FreezeRepresentation
}[DllImport("dwmapi.dll")]
private static extern int DwmSetWindowAttribute(IntPtr hwnd, DWMWINDOWATTRIBUTE attr, ref int attrValue, int attrSize);protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);
if (Environment.OSVersion.Version.Major >= 6)
{
int attrValue = 1;
int hr = DwmSetWindowAttribute(this.Handle, DWMWINDOWATTRIBUTE.TransitionsForceDisabled, ref attrValue, 4);
if (hr < 0)
Marshal.ThrowExceptionForHR(hr);
}
} -
Closing a dropdown box on a toolstrip itemIf I understood your question correctly, you have a ToolStripComboBox as an item of a ToolStripDropDownButton and want to close dropdown when an item of combobox is selected; so you can do this:
private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
((ToolStripItem)sender).PerformClick();
} -
can not copy database filesTry these:
string ConnStr = @"Data Source=.\SQLEXPRESS;Database=Master;Integrated Security=True";
SqlConnection mycon = new SqlConnection(ConnStr);
SqlCommand mycom = new SqlCommand("sp_detach_db", mycon);
mycom.CommandType= CommandType .StoredProcedure ;
mycom.Parameters.Add(new SqlParameter("@dbname", SqlDbType.NVarChar,50));
mycom.Parameters["@dbname"].Value = "mydb";
mycon.Open();
mycom.ExecuteScalar();
mycon.Close(); -
run a function before exiting a web applicationTake a look at this link: Dirty Panel Extender (ASP.NET AJAX)[^] It seems to be useful for you.
-
ToolStrip ScrollingYou can use a panel. 1- Place a panel on your form and dock it for example to left 2- Set the AutoScroll Property of panel to True. 3- Place your Toolstrip in your panel. 4- Set the AutoSize Property of ToolStrip to True and LayoutStyle to VerticalStackWithOverflow Or Table or Flow.
-
how to sync the data of two table?You can use "Instead Of" or "After" triggers on those tables for Insert, Update and Delete actions. For example:
USE YourDatabase CREATE TRIGGER Table1_AfterDelete ON Table1 AFTER DELETE AS DELETE Table2 WHERE Table2.Id IN (SELECT Id FROM DELETED) GO CREATE TRIGGER Table1_AfterInsert ON Table1 AFTER INSERT AS INSERT INTO Table2 SELECT * FROM INSERTED GO CREATE TRIGGER Table1_AfterUpdate ON Table1 AFTER UPDATE AS UPDATE Table2 SET Table2.FirstName=Table1.FirstName, Table2.LastName=Table1.LastName FROM Table2 JOIN Table1 ON Table2.Id=Table1.Id GO
-
Draw smooth text on Transparent bitmapThank you for your comment. But using GDI+, when you draw a text on transparnet background and save the image you will see that the font smoothing is completely good. It seems here font smoothing take place by Mixing Font color with Transparent color, using Alpha value in ARGB. Also Applications like Photoshop do the job well. So there should be a win32(GDI)approach to drawing smooth text on transparent bitmaps. in GDI+ the code is like to this:
Bitmap myBitmap=new Bitmap(100,100,Format32bppArgb); Graphic g=Graphics.FromImage(myBitmap); g.DrawString("Test", Font, Brushes.Black, 0, 0); myBitmap.Save("myBitmap.png",ImageFormat.Png);
-
Draw smooth text on Transparent bitmapHow can I draw smooth text on a transparent bitmap using GDI functions? What I do is: 1- Creating myBitmap 2- Creating Graphics object from myBitmap 3- Getting bitmap hDC 4- Setting background mode to TRANSPARENT 5- Drawing text using DrawText function 6- Releasing bitmap HDC 7- Saving Bitmap The result is an ugly text! the text is not smoothed but when I set background mode to OPAQ using SetBkMode the result is smoothed. How can I draw smooth text on a transparent bitmap using GDI functions? any help will be appreciated. My code is like this:
Bitmap myBitmap=new Bitmap(100,100,Format32bppArgb); Graphic g=Graphics.FromImage(myBitmap); IntPtr hDC=g.GetHDC(); SetBkMode(hDC, TRANSPARENT); DrawText(hdc, "Test", -1, myrectangle,myflags); g.ReleaseHdc(hDC); myBitmap.Save("myBitmap.png",ImageFormat.Png);
modified on Thursday, August 20, 2009 6:54 AM
-
Convert GlyphIndex to UnicodeHow can I convert Glyph Index to Unicode encoding? The GetCharacterPlacement API function is useful for convert a sequence of unicode carachters to Glyph Indices, but is there a solution for convert a sequence of Glyph Indices to unicode carachters? (I asked this question in c# forum but I received no reply) any help will be appreciated.
-
GraphicsPath.AddStringIs there any way to draw high quality text glyph by glyph using GDI+? When we draw a String using GraphicsPath.AddString, The SubPathes in the main path are glyph outlines. but it seems in small fonts the quality of Drawing string this way is not acceptable. Is the result of GraphicsPath.AddString equal to GetGlyphOutline API function? (I asked this question in c# forum but I received no reply) any help will be appreciated
-
GraphicsPath.AddStringIs there any way to draw high quality text glyph by glyph using GDI+? When we draw a String using GraphicsPath.AddString, The SubPathes in the main path are glyph outlines. but it seems in small fonts the quality of Drawing string this way is not acceptable. Is the result of GraphicsPath.AddString equal to GetGlyphOutline API function? any help will be appreciated
-
Convert GlyphIndex to UnicodeHow can I convert Glyph Index to Unicode encoding? The GetCharacterPlacement API function is useful for convert a sequence of unicode carachters to Glyph Indices, but is there a solution for convert a sequence of Glyph Indices to unicode carachters? any help will be appreciated.
-
Killing processes with listview (.net 2003)you can use this API function: Private Declare Function TerminateProcess Lib "kernel32" Alias "TerminateProcess" (ByVal hProcess As Integer, ByVal uExitCode As Integer) As Integer for an example of what you want you can see this link: Terminate a process immediately in VB.NET[^]
-
I want to read header file ( .avi)here is a good article that can help u: Steganography IV - Reading and Writing AVI files[^]
-
Printing Component Advicehere is an easy way: Dim bm As New Bitmap(Me.Width, Me.Height) Dim g As Graphics = Graphics.FromImage(bm) Me.DrawToBitmap(bm, New Rectangle(0, 0, Me.Width, Me.Height)) now you can customize this code to getting a bitmap that only contain client rectangle of your form. another way is: Public Class ScreenCapture _ Private Shared Function GetDesktopWindow() As IntPtr End Function _ Private Shared Function GetWindowDC(ByVal hwnd As IntPtr) As IntPtr End Function _ Private Shared Function BitBlt(ByVal hDestDC As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As IntPtr, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As System.Int32) As UInt64 End Function 'Save the screen capture into a jpg Public Shared Function SaveScreen() As Bitmap Dim myImage = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height) Dim gr1 As Graphics = Graphics.FromImage(myImage) Dim dc1 As IntPtr = gr1.GetHdc() Dim dc2 As IntPtr = ScreenCapture.GetWindowDC(ScreenCapture.GetDesktopWindow()) ScreenCapture.BitBlt(dc1, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, dc2, 0, 0, 13369376) gr1.ReleaseHdc(dc1) Return myImage End Function 'SaveScreen End Class 'NativeMethods
-
Adding New Row in Datagridviewyou can do some things like "Me.DataGridView1.Rows.Insert(..." or check sorting options of your binding source/your datagrid.
-
Usercontrol toolbox bitmap1- add your 16x16 bitmap to your project 2- the name of bitmap must be the same as your user control (YourControl.bmp) 3- in property tab of your bitmap, set build action to embeded recource 4- rebuild your project now after adding your control to toolbox you will see that bitmap. ---------------------------------- another way is using ToolboxBitmapAttribute