Category Archives: Windows Application

Open Notepad and Calculator from Windows Application C#

Open Notepad, Calculator and wordpad from Windows Application C#

How to open notepad and calculator control from windows application using c#.

Create windows Application — > windows forms

Open notepad and calculator in windows application C#

Open notepad and calculator in windows application C#

write below code on Notepad button control for open notepad through windows application.

 

Open notepad and calculator in windows application C#

Open notepad and calculator in windows application C#

The code for open calculator control from windows application using c#.

 

Open notepad and calculator in windows application C#

Open notepad and calculator in windows application C#

Here is the code for open wordpad from windows application using c#.

In this example the all the three process notepad, calculator and wordpad launch open on server side not on the client side.

How to Change Background Color of MDI Form in Windows Application.

Here, I explain how to change the background color of MDI form in Windows application.

If we set property IsMdiContainer=True windows form then all the rest of form will open with in it.
Here, Basically the concept of Child and Parents, the MDI form will behave a parents of and rest of all are child of that Mdi form.

If you set IsMdiContainer=True  then you will not able to change the background color of windows forms.
If you want to change the background color of Mdi forms then you have to right below code in Page_Load event of Mdi forms.

 C# Code

 private void Form1_Load(object sender, EventArgs e)
{
foreach (Control ctl in this.Controls)
{
try
{
System.Windows.Forms.Control Mdi = (MdiClient)ctl;

Mdi.BackColor = System.Drawing.Color.DarkSeaGreen;
}
catch (Exception a)
{
}
}
}

VB Code

For Each ctl As Control In Me.Controls
Try
Dim Mdi As System.Windows.Forms.Control = CType(ctl,MdiClient)
Mdi.BackColor = System.Drawing.Color.DarkSeaGreen
Catch a As Exception

End Try
Next

Create Windows Application Setup Project in Visual Studio 2008

Here, in this post i will explain how to create windows application setup project and how to Deployment windows setup project in visual studio 2008.

The Setup project output is setup file .msi and desktop shortcut icon of application and place icon in startup menu.

First step is to create setup project open visual studio 2008 and create new setup project from project tab as shown below figure.

 

Create Windows Application Setup Project in vs2008

Create Windows Application Setup Project in vs2008

Now, here is the home screen of setup project created. there are main three part of setup project the Application Folder, User’s Desktop  and User’s Programs Menu.

Application Folder : In Application Folder we will add our .exe file to create .msi file setup project.
User’s Desktop : create Desktop icon for open application
User’s Programs Menu : show the application icon in start up Programs Menu.

Create Windows Application Setup Project in vs2008

Create Windows Application Setup Project in vs2008

The below screen show the solution explorer of setup project.

Create Windows Application Setup Project in vs2008

Create Windows Application Setup Project in vs2008

Next step is go to the property of setup project and change ProductName, and set RemovePreviousVersion Property to True.

Create Windows Application Setup Project in vs2008

Create Windows Application Setup Project in vs2008

 

Now, Add the .exe file of  Windows application in Application Folder >> Add >> File.

Create Windows Application Setup Project in vs2008

Create Windows Application Setup Project in vs2008

 

After Adding .exe file in Application Folder set the Application Folder Property AlwaysCreate=True.

Create Windows Application Setup Project in vs2008

Create Windows Application Setup Project in vs2008

Now, Create the project shortcut icon on Desktop, Add File from Application Folder to User’s Desktop.  Right click of right side portion of User’s Desktop and select Create New Shortcut and browse the .exe file from Application Folder tab.

 

Create Windows Application Setup Project in vs2008

Create Windows Application Setup Project in vs2008

 

Set User’s Desktop Property AlwaysCreate=True.

Create Windows Application Setup Project in vs2008

Create Windows Application Setup Project in vs2008

Here, below screen show how to brows and add .exe file on user’s Desktop from Application Folder.

Create Windows Application Setup Project in vs2008

Create Windows Application Setup Project in vs2008

Create Windows Application Setup Project in vs2008

Create Windows Application Setup Project in vs2008

Now, if you want to create a shortcut in start/Allprograms , just Add folder in User’s Program Menu by right click on User’sProgram Menu add Folder and make same process as User’s Desktop Menu. Add .exe file to User’s Program Menu newly created folder. Right click on newly created folder and add shortcut as we did above user’s desktop.

Create Windows Application Setup Project in vs2008

Create Windows Application Setup Project in vs2008

 

Create Windows Application Setup Project in vs2008

Create Windows Application Setup Project in vs2008

Finally, the change the version of setup project. every time we release new setup change the version property of setup project.

Create Windows Application Setup Project in vs2008

Create Windows Application Setup Project in vs2008

After finishing all step just build your application and you will get .msi file at debug folder and shortcut icon on Desktop and same icon in start/ All Program menu.

How to Bind CheckedListBox control in windows form application

In this article I will explain you how to bind  from database to CheckedListbox control  in windows forms application in asp.net.

first we need to create database for bind data to checkedlistbox control in windows application.

Here, we create database in sql server, database name is :Example

Create a Table in Database, Table name is : UserMst
Design table with 1 column named UserName.

UserName as nvarchar(50) datatype Allow null = Yes

After completion of design table enter some values in table manually for our example.

Now, design a windows for with one CheckedListbox control along with one Button control.

Checkedlistbox control in wondows application

How to Bind Data to Checkedlistbox control in wondows application

write below code on button click event for bind data from database to checkedlistbox control.

private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(“Data Source=’.\\SQLEXPRESS’;Integrated Security=’true’;Initial Catalog=’Example'”);
SqlDataAdapter Adp = new SqlDataAdapter(“SELECT UserName FROM UserMst”, con);
DataTable DT = new DataTable();
Adp.Fill(DT);

for (int i = 0; i < DT.Rows.Count; i++)
{
checkedListBox1.Items.Add(DT.Rows[i][“UserName”].ToString());
}
}

Checkedlistbox control in wondows application

How to Bind Data to Checkedlistbox control in wondows application

Ckeck / UnCheck All Items in CheckedListbox control in windows application

Hi, here we will learn how to check / uncheck all items from checkdlistbox control by clicking button in windows forms application.

we will learn it with an example in windows form application.

First, design the windows form like below, tack one CheckedListbox control along with two linkbutton for checked and unchecked checkedlistbox control.

CheckedListbox control in windows forms application.

Check / Uncheck CheckedListbox control in windows forms application.

Here, we have two link button for Check all items form CheckedListbox and Unchecked all items from CheckedListbox control in windows forms application.

when we click button ALL then all the items in checkedlistbox will be checked / selected.

write below code in ALL button click event for Checkde all items in Checkedlistbox control.

private void lnkALL_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
checkedListBox1.SetItemChecked(i, true);
}
}

For Uncheckd all items in Checkedlistbox control click NONE button.

write below code in NONE button click event for unchecked all items in checkedlistbox control.

private void lnkNONE_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
checkedListBox1.SetItemChecked(i, false);
}
}

CheckedListbox control in windows application.

Check / Uncheck CheckedListbox control in windows forms application.

Check / Uncheck CheckedListbox control in windows forms application.

I hope, this chekced / unchecked checkedlistbox control will help you…..

Autocomplete Textbox from database in windows forms Application

In this article I will explain you how to implement autocomplete textbox from database in windows forms Application in asp.net.
first we need to create database for implement autocomplete textbox in windows application.
Here, we create database in sql server, database name is :AutoComplete

Create a Table in Database, Table name is : UserMst
Design table with 1 column named UserName.

UserName as nvarchar(50) datatype Allow null = Yes

After completion of design table enter some values in table manually for our example.

Now, design a windows for with one TextBox control ID = txtName

First set two main TextBox control property for autocomplete.

autocomplete textbox

autocomplete textbox from database in windows forms application

AutoCompleteMode = Suggest , Append or SuggestAppend
Set anyone from three of above for autocomplete textbox

AutoComlateSource = CustomSource

autocomplete textbox

autocomplete textbox from database in windows forms application

After doing this write below code at Form_Load event of windows form

private void Form1_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(“Data Source=’.\\SQLEXPRESS’;Integrated Security=’true’;Initial Catalog=’AutoComplete'”);
SqlCommand cmd = new SqlCommand(“SELECT UserName FROM UserMst”, con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
AutoCompleteStringCollection SCollection = new AutoCompleteStringCollection();
while (reader.Read())
{
SCollection.Add(reader.GetString(0));
}
txtName.AutoCompleteCustomSource = SCollection;
con.Close();
}

autocomplete textbox

autocomplete textbox from database in windows forms application

autocomplete textbox

autocomplete textbox from database in windows forms application

After write above code in load event just run your windows form and enjoy autocomplete textbox from database in windows application.

Timer control in c# windows application

We will make one example for understanding timer control in c# windows application.

Here, we display current Date and time on windows form using timer windows control.

First we design windows form using Label control for Display current Date and time using Timer control in asp.net c#.

Timer control in c# windows application

Timer control in c# windows application

In above figure we took a timer control from toolbox on windows form in asp.net

Now tack label control on windows form for display current time and date.

Below figure we can see the static time on label control in windows application….

Display current Date and Time in windows application

Display current Date and Time in windows application

write below code on page load event of windows form.

lbltime.Text = System.DateTime.Now.ToString();
lblday.Text = System.DateTime.Now.DayOfWeek.ToString();

If we want to display running time on label control so we need to use timer control timer_tick event..

Timer_Tick event fire according to the properties of Timer Interval of timer control.

Timer control in windows application

Timer control in windows application

what is ajax in asp.net?

How to use ajax timer control in asp.net

Now we can write below code on Time_tick Events

private void timer1_Tick(object sender, EventArgs e)
{
lbltime.Text = System.DateTime.Now.AddSeconds(1).ToString();
}

and write below code on page load event for display date and time on windows form.

private void Form1_Load(object sender, EventArgs e)
{
lbltime.Text = System.DateTime.Now.ToString();
lblday.Text = System.DateTime.Now.DayOfWeek.ToString();

lbldate1.Text = System.DateTime.Now.GetDateTimeFormats()[2].ToString();
lbldate2.Text = System.DateTime.Now.GetDateTimeFormats()[3].ToString();
lbldate3.Text = System.DateTime.Now.GetDateTimeFormats()[5].ToString();
lbldate4.Text = System.DateTime.Now.GetDateTimeFormats()[8].ToString();
lbldate5.Text = System.DateTime.Now.GetDateTimeFormats()[10].ToString();
}

The out put of time control in c# windows application is:

date and time format in windows application c#

date and time format in windows application c#

In above figure we can see the different date and time format in windows application c#.

I hope this timer control example for displaying current date and time will help you……..

How to Disable Tab Pages in Tab Control in Windows Application C#

Hi, Here we are going to learn about Windows application Tab Control in asp.net.

Tab control is used to display multiple dialog on single Windows Form. we can switch from one tab pages to other in Tab control in Windows application with c# controls.

All single dialog tab known as a Tab pages… one Tab control has multiple Tab Pages and we can add or remove Tab pages in Tab Control…

Here we lean How to Disable one or more Tab pages in Tab control in asp.net.

So, We have a property Enabled for Enable and Disable Tab pages effects…

tabPage1.Enabled = false;

tabPage3.Enabled = true;

But, here we want to Disable Tab page click event, means we can not click on that Tab pages so we need to do follow method….

First design windows form with one Tab control with Three Tab pages in asp.net c#.

Here we show you First Tab page is normal as simple and Second Tab page Click event is Disable and we make Third tab page Enabled false…..

Here in below figure1 we can see the simple out put of Tab page 1 click event…

Disable Tab pages in Tab control in Windows Application.

Disable Tab pages in Tab control in Windows Application.

Write below code in tabcontrol selectedindexchanged events…

private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedTab == tabPage2)
{
tabControl1.SelectedTab = tabPage1;
MessageBox.Show(“You don’t have permission !!”, “Meera Academy”);

}
if (tabControl1.SelectedTab == tabPage3)
{

tabPage3.Enabled = false;
}
}

Now, when we click on Tab page2 then we can get message like you don’t have permission to click this tab pages.

Here we have Disable Tab page 2 click event in Tab control in ASP.Net with c# controls.

How to disable tab pages click event in tab control c#

How to disable tab pages click event in tab control c#

The last Third Tab page 3 click event is not disabled but the Content of tab pages3 is is Disable so we cant see the out put of like below screen……

How to disable tab pages click event in tab control c#

How to disable tab pages click event in tab control c#

I hope you will enjoy this Enabled/Disable Tab pages Click event in Tab page c# controls in Windows application……