This article will show you how you can how you can set focus
on textbox in windows application using c#.net. In this when we click on button
the focus from one textbox to other textbox will shift.
Some of my previous articles are as follows: Limit
OR Restrict Number of Characters in Textbox C#.Net In windows Application, AutoSuggest
DropDownList In Windows Application Using C#.Net, Random
Character and String Generation Using C#.Net, Windows Application and Linq,
Strong
Random String Password Generation Using C#.Net, Login
Form By UserType OR User Role In Windows Application In C#.Net , Linq, Display
Message With Warning icon in Windows Application Using C#.Net, Stylish
ToolStrip Button Control With Image and Text Control In Windows Application
Using C#.Net, No
of Days Between Two Dates By Using TimeSpan In Windows Application In C#.Net
and VB.Net, Validate
Directory Exist or Not in C#.Net In Windows Application.
So for this article first we will create a new windows application and add the two textbox and a button control.
After adding this we will add the below code on the button
click.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void button1_Click(object
sender, EventArgs e)
{
textBox2.Focus();
}
}
}
|
In above code check the bold part of the code. This piece of
code will transfer the focus on textbox two. Now run the application and check
the output.
0 comments:
Please let me know your view