Archive for the ‘Programming’ Category

How to Text Wrap a Label in WPF?

WPF does not allow text wrapping for label control.Thus to wrap a label with a fixed width,we have to place the TextBlock control inside the label control and set its TextWrapping property to “Wrap”.

<Label Width=”50″>
<TextBlock TextWrapping=”Wrap”> I am label with width 50</TextBlock>
</Label>

Popularity: 9% [?]

How to set border color of a panel in c#

In c# for panel there no property to set border color directly.We can only set the border style using BorderStyle.

To set the border color of a panel,

Step 1 : Set BorderStyle property to None.

Step 2 : Draw a rectangle and set the pen color in paint event of the panel

private void panelpanelbordercolor1_Paint(object sender, PaintEventArgs e)
{
  e.Graphics.DrawRectangle(Pens.Red,
  e.ClipRectangle.Left,
  e.ClipRectangle.Top,
  e.ClipRectangle.Width - 1,
  e.ClipRectangle.Height -1);
  base.OnPaint(e);
}

Source Link

Popularity: 19% [?]

How to convert from .class file to .java file in Java

Step 1: Download Java – Decompiler from

http://download.cnet.com/windows/3055-2213_4-10046809.html?tag=pdl-redir

Step 2: Install the Java – Decompiler in your PC.

Step 3: Go to All Programs –> DJ Java Decomplier –> DJ Java Decomplier.

Step 4: Select File –> Open then Choose the Class File in File Dialog box.

djopendialogjpg

Step 5: Java File is created from class File.

javafilejpg

Popularity: 16% [?]

How To Call a Button Click From Another Button in c#

If there is a requirement for calling a button click event from another button in c#, there is a easy way to do.We just need to call the PerformClick Method of the button to be fired.

private void button1_Click(object sender, EventArgs e)
{
    button2.PerformClick();
}
 
private void button2_Click(object sender, EventArgs e)
{
    System.Windows.Forms.MessageBox.Show("I am called from button1");
}

Popularity: 10% [?]

Java 1.5 features

  • Generics: provides compile-time (static) type safety for collections and eliminates the need for most typecasts (type conversion).
  • Metadata: also called annotations; allows language constructs such as classes and methods to be tagged with additional data, which can then be processed by metadata-aware utilities.
  • Autoboxing/unboxing: automatic conversions between primitive types (such as int) and primitive wrapper classes (such as integer).
  • Enumerations: the enum keyword creates a typesafe, ordered list of values (such as day.monday, day.tuesday, etc.). Previously this could only be achieved by non-typesafe constant integers or manually constructed classes (typesafe enum pattern).
  • Swing: new skinnable look and feel, called synth.
  • Var args: the last parameter of a method can now be declared using a type name followed by three dots (e.g. Void drawtext(string… Lines)). In the calling code any number of parameters of that type can be used and they are then placed in an array to be passed to the method, or alternatively the calling code can pass an array of that type.
  • Enhanced for each loop: the for loop syntax is extended with special syntax for iterating over each member of either an array or any iterable, such as the standard collection classesfix the previously broken semantics of the java memory model, which defines how threads interact through memory.
  • Automatic stub generation for rmi objects.
  • Static imports concurrency utilities in package java.util.concurrent.
  • Scanner class for parsing data from various input streams and buffers.
  • Assertions
  • StringBuilder class (in java.lang package)

Popularity: 11% [?]

Make Textbox Number Only – WPF

Coding :

private void txt_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !ValidNumeric(e.Text);
base.OnPreviewTextInput(e);
}
 
bool ValidNumeric(string str)
{
bool ret = true;
 
int l = str.Length;
for (int i = 0; i &lt; l; i++)
{
char ch = str[i];
ret &= Char.IsDigit(ch);
}
 
return ret;
}

Thanks dedjo

Popularity: 5% [?]

How to open Immediate Window In VS 2005- Shortcuts

The Immediate window is used to debug and evaluate expressions, execute statements, print variable values etc.The Immediate window also supports IntelliSense.There are different methods to open Immediate window.

Method 1 : -
We can open Immediate Window from debug menu.

Debug->Windows->Immediate Window

immediate

Some times Immediate Window menu would be missing.If it seems to be missing for you then you can get the Immediate Window menu by going to Tools->Customize and then select the Commands tab, choose for Debug commands and drag Immediate onto the toolbar.Read more about this issue here.

Method 2 : -

Use the Keyboard Shortcut keys Ctrl+Alt+I

Method 3 : -
We can also open Immediate Window through VS Command window.Just type “immed” in the prompt and hit enter Immediate Window will open.

commimmed

For more details about Immediate Window go to MSDN Link

Popularity: 14% [?]

Steps to Create Setup and Deployment Project in Dot Net VS 2008

Step 1
Create your own windows application. Create a new Windows application project in C# and named it as Sample.

d01

Step 2

Design your own application. Here we have a simple login form for example.

d02
Step 3
After completing the design and coding, build the solution of the project in release mode.

d03

Step 4
Check the Release folder for the file “ProjectName.exe”. Here in this example we have the project name as sample so we can find a file with the name Sample.exe. Double click the executable file and check the example.

d04

Step 5
Create a Deployment Project. Select the “Other Project Types” -> “Setup and Deployment” -> “Setup project”. Here we have the setup project for example as “SampleSetup”.

d05

Step 6
Add the Sample.exe project application file inside the “Application Folder”.

d06

Step 7

To make a shortcut for the project right click “File System on Target Machine” and create shortcut of the application. Here in this example the project shortcut is created in program files folder.

d07

Step 8
Create the shortcut of the application.

d08

Step 9
Rename the shortcut of the application.

d09

Step 10
Move the Shortcut file to specified target. Note if you need another shortcut for some other target also create use same steps.

d10

Step 11
Now build the solution in release mode.

d11

Step 12
The setup file created in release folder of the project specified path.

d12

Step 13
Run the setup, step the path to extract.

d13

d14

d15

Step 14
The SampleSetup project is extracted and shortcuts are created. Now run your application.

d16

Popularity: 100% [?]

How to Get The List Of All Tables in a Database – Sql Server 2005

We a can get the list of all tables of a database in different ways : -

1.

SELECT *
FROM sys.TABLES

2.

SELECT *
FROM sysobjects
WHERE TYPE='U'

3.

SELECT *
FROM information_schema.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'

Popularity: 2% [?]

View Existing Triggers – Drop One or More Triggers in Sql Server 2005

To view the existing triggers in the database

SELECT * FROM sys.triggers
OR
SELECT * FROM sysobjects WHERE xtype='TR'

To view the existing triggers in a specified table

sp_helptrigger tablename

To drop a trigger

DROP TRIGGER triggername

To drop more triggers at a time

DROP TRIGGER [trigger1],[trigger2],[trigger3]...[triggern]

Popularity: 12% [?]

Designed by: Business Web Hosting | Thanks to Buy Icons, travel tips and Used Cars