Subscribe For Free Updates!

We'll not spam mate! We promise.

Showing posts with label Windows Forms. Show all posts
Showing posts with label Windows Forms. Show all posts

Jul 20, 2016

Create Installer Projects in Visual Studio 2013

Views:

After completing the development of your desktop Application. The next phase is to deployment or installation of that application.

For this you need to create a setup of your project, then you just need to give the setup file to the users or your client so they can install and use your application.

In Visual Studio 10 or prior edition, has built in functionality to create setup file using Installer Projects. But in Visual Studio 13 and next edition you need to install an extension first and then you can create.

Jun 17, 2013

Create Setup File in Visual Studio 2010

Views:

Today I will show you how to create setup or .exe file of your project in Visual studio 2010.

The setup file is very important and After making setup file any one can install your software on respected operating Systems.

So it very necessary for a Developer or Programmer to know how to create a Setup file and How to Deploy or install it on any Operating system.



Oct 9, 2012

Print Document In Windows Forms Using C#

Views:

To Day I will show you How to Print a Document   in Windows Forms (.NET) using C# .

For Printing a Document or text From Text box or Data From Grid View we Use Print Dialog  Control From Toolbox tab in Windows Forms.
A Print Dialog control is used to open the Windows Print Dialog.
This Control  allows users to send an output to a printer. With the help of Print Preview Dialog You can preview a document Before Print it (Like in MS word).

Aug 19, 2012

SMS Send and Receive Using AT Commands Complete Source Code

Views:

SMS Send and Receive Using AT Commands Complete Source Code
In Today's article i will demonstrate you How to send and received sms in C# using AT Commands with Complete Source Code.
In This Tutorials I will not use any sms sending and Receiving API , but Learning this Post Completely Care fully INSHA Allah you will be able Develop your Own SMS sending and Receiving API or Classes according to your requirement.
In This tutorials i will use AT commands .AT commands are the Commands which communicates and Controls  your Mobile or GSM Modem for Sending and Receiving SmS, you may also Get other Information like Signals Strengths Etc. So it is Recommended for you Before reading this Tutorials to go through AT commands. Following are the links which will help you develop the base :-

Jul 30, 2012

Grid View Copy Paste In Excel File

Views:

Grid View Copy Paste In Excel File
Today I Show how to Copy Paste Data In Data Grid View From an Excel File and From Excel From Copy Paste To Grid View .
As we know that Is Excel is A Grate Product of Microsoft. Excel File is most Probably use From Reporting , Graphs Making and Etc.  
User Always Wants Easiness in Software Application .

Copy Paste From Grid View to Excel File Provide Easy Ways for Reporting and Graphs Making.Excel File Copy Paste To Grid View Save Data Entry Operator Time and After Pasting  Data To Data Grid View We can Easily Save it To Data Base Just by clicking Button.

So lets start
First Drag Drop an Data Grid View on Windows Forms
Create  Columns in Data Grid View ID ,StudentName, Class,Sec,Batch,Fees.
Grid View Copy Paste In Excel File


Grid View Copy Paste In Excel File
 
First We enable Grid View to Copy data In Clip Board by writing Following line in Page load Event.
this.dataGridView1.ClipboardCopyMode = 
    DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
and Write Download The Following Method For Copy Paste.
private void PasteClipboard()
        {
            try
            {
                string s = Clipboard.GetText();
                string[] lines = s.Split('\n');
                int iFail = 0, iRow = dataGridView1.CurrentCell.RowIndex;
                int iCol = dataGridView1.CurrentCell.ColumnIndex;
                DataGridViewCell oCell;
                foreach (string line in lines)
                {
                    if (iRow < dataGridView1.RowCount && line.Length > 0)
                    {
                        string[] sCells = line.Split('\t');
                        for (int i = 0; i < sCells.GetLength(0); ++i)
                        {
                            if (iCol + i < this.dataGridView1.ColumnCount)
                            {
                                oCell = dataGridView1[iCol + i, iRow];
                                if (!oCell.ReadOnly)
                                {
                                   
                                   
                             oCell.Value = Convert.ChangeType(sCells[i],
                                                       oCell.ValueType);
                             oCell.Style.BackColor = Color.Tomato;
                                   
                                    
                                }
                            }
                            else
                            { break; }
                        }
                        iRow++;
                    }
                    else
                    { break; }
                    if (iFail > 0)
                        MessageBox.Show(string.Format("{0} updates failed due" +
                                        " to read only column setting", iFail));
                }
            }
            catch (FormatException)
            {
   MessageBox.Show("The data you pasted is in the wrong format for the cell");
                return;
            }
        }


Now Write Some Code Behid in  dataGridView1_MouseClick Event For Display The Context menu
if (e.Button == MouseButtons.Right)
            {
                ContextMenu m = new ContextMenu();

                
   m.MenuItems.Add(new MenuItem("Paste"),, new EventHandler(BtPasteClick));
    var relativeMousePosition = dataGridView1.PointToClient(Cursor.Position);
      m.Show(dataGridView1, relativeMousePosition);


            }

and also Add Following Method same as it is After Above Method
private void BtPasteClick(object sender, EventArgs e)
        {
            string s = Clipboard.GetText();
            if (s.Length > 0)
            {
                PasteClipboard();
            }
            else
            {
                MessageBox.Show("Please Copy Some Data First "
                    , "[MOHAMMAD SAJJAD ASHRAF AWAN]"
                    , MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }

So that it .
When You Copy Paste Data Always Remember Following Things .
1) Always Copy Equal Number of Cells mean When you Copy Data from Excel Must Copy equal or Less No. of Cells  According to Data Grid view .
2)You Must Add No .of Empty Row to Grid view  That you are Going to Paste.
3)always select Initial Cell of Grid View to Paste Data.

DOWNLOAD SOURCE CODE

SOME OUTPUT SCREEN SHORTS

Grid View Copy Paste In Excel File



Grid View Copy Paste In Excel File
Grid View Copy Paste In Excel File


Jul 26, 2012

Eamil , Phone number and String Validation in Windows Forms

Views:

Eamil , Phone number and String Validation in Windows Forms
Today I show you how to Validate Email address,Phone or mobile numbers and String validation in Winodows froms c#.

As we in asp.net there is a validation control that can easily validate required String.

Here but use regex Expressions for Email Validations .It is Easy and most widely use Technique .


So let start,
first you have to drag drop Text box And Button on Form Designer Surface .

Created a method like below
bool IsvalidEmail(TextBox Email)
        {
                        if (Email.Text.Trim() != "")
            {
 Match rex = Regex.Match(Email.Text.Trim(' '), "^([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z]"+
        "[-\\w]*[0-9a-zA-Z]\\.)[a-zA-Z]{2,3})$", RegexOptions.IgnoreCase);
                if (rex.Success == false)
                {
                    MessageBox.Show("Please Enter a valid Email-Address ",
                    "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Email.Focus();
                    return false;
                }
                else
                {
                    return true;
                }
            }
            else

            {
                return true;

            }
        }

And Write this Code In OnClick Eent of Button

        private void btShow_Click(object sender, EventArgs e)
        {
            bool Vaild = IsvalidEmail(txtEmail);
            if (Vaild)
            {
                MessageBox.Show("Email address is Correct");
            }
          
        }

Little Description about REGX

Patter   Description
(@)               Match the @ character. This is the first capturing group.
(.+)               Match one or more occurrences of any character. This is the second
              capturing group.
$               End the match at the end of the string.
|(([0-9a-zA-Z]     If the first character is not a quotation mark, match any alphabetic
                            character from a to z or  any numeric character from 0 to 9.

 AND NOW PHONE NUMBER and STRING VALIDATIONS

It is very Simple and Easy you just Write Below code on KEY_Press Event of a textbox.

 private void txtCellNumber_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsNumber(e.KeyChar) && e.KeyChar != (char)Keys.Back && e.KeyChar != '+')
            {
                e.Handled = true;
            }
        }

For String

 private void txtStringValue_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsLetter(e.KeyChar))
            {
                e.Handled = true;
            }
        }

Download Soucre Code

Become a Fan

visual studio learn