Search This Blog

Wednesday, October 16, 2013

Determine control ToolStripItem was clicked on

C# > Controls > ContextMenuStrip


Scenario:
We have many labels on forms and one ContextMenuStrip. How can we find the control which was clicked?

Solution:

private void copyToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            ToolStripItem menuItem = sender as ToolStripItem;
            if (menuItem != null)
            {
                ContextMenuStrip owner = menuItem.Owner as ContextMenuStrip;
                if (owner != null)
                {
                    Control sourceControl = owner.SourceControl;
                    Label lbl = sourceControl as Label;
                }
            }
        }





Monday, October 14, 2013

Print preview dialog full screen C#

C# > PrintPreviewDialog > Full Screen



PrintPreviewDialog dlg = new PrintPreviewDialog();
((Form)dlg).WindowState = FormWindowState.Maximized;
dlg.ShowDialog();





Center DIV

CSS margin property sets all the margin properties (top, right, bottom, left).

<div style="border: thin solid #C0C0C0; width: 800px;margin:0 auto;">
        centered content
</div>





Sunday, October 6, 2013

Remove Qone8 browser hijacker malicious software

Qone8 is a browser hijacker, which is installed via other free downloads, and once installed it will change your browser homepage to start.qone8.com and default search engine to search.qone8.com.
It is considered malicious because it will append the argument http://start.qone8.com/ to random Windows shortcuts on your desktop and your Windows Start Menu.






Remove instructions:

1. Go to your software browser shortcut. Right click and then click on Properties

2. Goto to Shortcut Tab and than delete the text appears rights to name of the executable (argument value)


3. Goto to Internet options and change the home page

4. Close and restart your browser

Saturday, September 21, 2013

Read Connection String From Web.Config VB.Net

VB.NET > Data > SqlConnection > ConnectionString
 
Dim con As SqlConnection
Dim conString As String = System.Configuration.ConfigurationManager.ConnectionStrings("ConnectionString").ToString
con = New SqlConnection(conString)
con.Open()




Wednesday, September 18, 2013

Modifier Protected Internal C#

C# > Keywords > internal

Protected Internal variables/methods are accessible within the same assembly and also from the classes that are derived from this parent class.

Example

public class MyClass 
{
    // Only accessible within the same assembly
    internal static string name = "MyClass";
}




ACID SQL

ACID is an acronym for atomicity, consistency, isolation, and durability.

Atomicity
One transaction is atomic. An atomic transaction is either fully completed, or is not begun at all.  If for any reason an error occurs and the transaction is unable to complete all of its steps, the then system is returned to the state it was in before the transaction was started.





Consistency
A transaction enforces consistency in the system state by ensuring that at the end of any transaction the system is in a valid state. If the transaction completes successfully, then all changes to the system will have been properly made, and the system will be in a valid state. If any error occurs in a transaction, then any changes already made will be automatically rolled back.
Isolation
When a transaction runs in isolation, it appears to be the only action that the system is carrying out at one time. If there are two transactions that are both performing the same function and are running at the same time, transaction isolation will ensure that each transaction thinks it has exclusive use of the system.
Durability
A transaction is durable in that once it has been successfully completed, all of the changes it made to the system are permanent. There are safeguards that will prevent the loss of information, even in the case of system failure.