Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Wednesday, May 28, 2014

Create an invisible password in Windows Application using C#

To day in this tutorial I will show you how to make an textbox in password mode without changing its TextMode property to Password.

I make this more simple by explaining the output of this program,

As an output there will be a textbox for inputing your password. But it will not show any charecter that will be written in the textbox, ie. invisible.

Create a new project and add a new form with a textbox, label & a button. Now on the TextChange event of the textbox write the code.


 label1.Text = label1.Text + textBox1.Text;
 textBox1.Text = "";

Make sure your label's  visible property if false.

Now in the button click event write down the code.

 label1.Text = "Your password : " + label1.Text;
 label1.Visible = true;

Now test your application.
Download the full source code here.

Thursday, May 22, 2014

Create random password in ASP.NET C#

In this tutorial I will show you how to make a random generate password in C#. You can apply it either in web application(ASP.NET) or in windows application.

Create a new project and add a web form or a win form as per your project. And then add a button. On the Button_Click() write the following code.


PasswordGenerator obj_p = new PasswordGenerator();
string new_password = obj_p.Generate();

Now you have to create a new class named PasswordGenerator and create a new method Generate.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
 
namespace <Project_Name>
{
    public class PasswordGenerator
    {
        public PasswordGenerator() { }
 
        /// <summary>
        /// Password generator method
        /// </summary>
        /// <returns></returns>
        public  string Generate()
        {
            var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
            var stringChars = new char[8];
            var random = new Random();
 
            for (int i = 0; i < stringChars.Length; i++)
            {
                stringChars[i] = chars[random.Next(chars.Length)];
            }
            var finalString = new String(stringChars);
            return finalString.ToString();
        }
    }
}

Now run the project and get the new password in the string new_password.

Happy coading :)

Wednesday, May 21, 2014

How to bind a DataGridView in a Windows project C#

Here I will show you how to bind a DataGridView in a windows application with a DataSet and SQLDataSource.

First  create a new windows project and add a new form. After that select a DataGridView and drag and drop into the form.


Now choose a new DataSource against the DataGridView.

Select New DataSource and click on the "Add Project Data Source".


Select the Database to proceed.



Now select the DataSet to continue.


Select the ConnectionString and click on the Next button.


Now after that choose the table name which one you want to display. You can choose multiple tables or views.


After that click on the Finish button to complete the process. Now in the bottom of the project you can see there is a DataSet named tblMessage. Open that and remove the columns that you don't want to display.


Now in the View Code section you can see in the Form_Load a new line of code is added. This one is binding the DataGdridView with the DataSet.

Now run the project and you will see in the output your database's table in the DataGridView.


Tuesday, March 4, 2014

Quiz software using C# (Windows application) with Ms. Access

In the previous post I had show you how to use Ms. Access as your database. Now in this article I will explain you how to create a Quiz software. First take a look about the database.

Here I have done all the program in just one form. And using panel I did all the hiding and showing data.

Table Question (tblQuestion)

  • ID (Number auto increment by 1)
  • Question (Text)
  • Option1 (Text)
  • Option2 (Text)
  • Option3 (Text)
  • Option4 (Text)
  • Answer (Text)

MS. Access connection with C# in windows or web application

Ms. Access is very useful database for the standalone application, where you need to run the program without installing the database in user's machine like a quiz or any other examination system. So lets have a look how to code the program to connect your software with Ms. Access database.

If you have done previously to connect the SQL server and done fetching or retrieving data from database it is more or less same for you. Everything is same except the connection string.

The Ms. Access connection string is here for you, with example of how to run a query(get or insert) in web application or windows application using of  C#.

You must hear about the OleDbConnection in .NET, we are going to use this one to connect your Ms. Access database.

Popular Posts

Pageviews