Dot Net WindowsForms Interview Questions And Answers
Download Dot Net WindowsForms Interview Questions and Answers PDF
Sharpen your Dot Net WindowsForms interview expertise with our handpicked 21 questions. Our questions cover a wide range of topics in Dot Net WindowsForms to ensure you're well-prepared. Whether you're new to the field or have years of experience, these questions are designed to help you succeed. Get the free PDF download to access all 21 questions and excel in your Dot Net WindowsForms interview. This comprehensive guide is essential for effective study and confidence building.
21 Dot Net WindowsForms Questions and Answers:
Dot Net WindowsForms Job Interview Questions Table of Contents:
1 :: How to get records from a database?
You have to get the "dotnet driver" of the database (or any
other datasource) you want to access to.
For example:
MySQL: Connector/Net
Access: Microsoft Access Driver
Oracle: Oracle Data Access Components (ODAC)
Afterwards you build a connection string to tell your
programm which driver you want to use and where the
datasource can be found, for example:
public const string DB_CONN_STRING =
"Driver={Microsoft Access Driver (*.mdb)}; "+
"DBQ=D:\\CS\\TestDbReadWrite\\SimpleTest.mdb";
Afterwards you just have to open a connection to the
database using the previously created connection string and
send a query to the database to get the record:
ADOConnection conn = new ADOConnection(DB_CONN_STRING);
conn.Open();
ADODataReader dr;
ADOCommand cmd = new ADOCommand( "SELECT * FROM <table>",
conn );
cmd.Execute(out dr);
while (dr.Read()){
....}
Read Moreother datasource) you want to access to.
For example:
MySQL: Connector/Net
Access: Microsoft Access Driver
Oracle: Oracle Data Access Components (ODAC)
Afterwards you build a connection string to tell your
programm which driver you want to use and where the
datasource can be found, for example:
public const string DB_CONN_STRING =
"Driver={Microsoft Access Driver (*.mdb)}; "+
"DBQ=D:\\CS\\TestDbReadWrite\\SimpleTest.mdb";
Afterwards you just have to open a connection to the
database using the previously created connection string and
send a query to the database to get the record:
ADOConnection conn = new ADOConnection(DB_CONN_STRING);
conn.Open();
ADODataReader dr;
ADOCommand cmd = new ADOCommand( "SELECT * FROM <table>",
conn );
cmd.Execute(out dr);
while (dr.Read()){
....}
2 :: How barcode create in the report?
Its very easy.
1-Take a barcode font like we used Arial, Time new Roman
2-Install this font at window fonts directory
3-Use Steric (*) at both ends of a field of Report with the
help of double/single commas
4.Change this field Font Like from Time new roman to
Barcode font
e.g Bar is field that contain digit from 1 to 8 as shown
below
*12345678*
After changing font these digit were converted into Black
Lines mean barcode
|||||||||||||||
5-Take print of barcode and enjoy.
Read More1-Take a barcode font like we used Arial, Time new Roman
2-Install this font at window fonts directory
3-Use Steric (*) at both ends of a field of Report with the
help of double/single commas
4.Change this field Font Like from Time new roman to
Barcode font
e.g Bar is field that contain digit from 1 to 8 as shown
below
*12345678*
After changing font these digit were converted into Black
Lines mean barcode
|||||||||||||||
5-Take print of barcode and enjoy.
3 :: How save rerecord in the database?
Dim Query
Query="insert into TableName(username)values('" &
txt_username.text & "')"
Dim cmd as sqlclient.sqlcommand=new
sqlclient.sqlcommand(Query,connection)
cmd.ExecuteNonquery()
Read MoreQuery="insert into TableName(username)values('" &
txt_username.text & "')"
Dim cmd as sqlclient.sqlcommand=new
sqlclient.sqlcommand(Query,connection)
cmd.ExecuteNonquery()
5 :: What are the new events in textbox that has been included in VB?
validate event to cntrl
Read More6 :: What is the Difference between listbox and combo box?
In List Box we have to choose one of the option from the
drop down list
In Combo just like radio button we have to choose any one
Read Moredrop down list
In Combo just like radio button we have to choose any one
7 :: Which property of menu cannot be set at run time?
Item property cannot be set at runtime.
Read More8 :: What is the difference between Listindex and Tab index?
Listindex : This property is used to check the index value
of the items in the Listbox
Tabindex : This property is used to set the flow of
controls in the form when we press the tab button.
Read Moreof the items in the Listbox
Tabindex : This property is used to set the flow of
controls in the form when we press the tab button.
9 :: What is the need of z-order method?
Z order method is the use of the show the design of the
output form to use z order technique.
z order technique is Show view of the Z corner to print the
z style.
Z order is Access the data in the two dimension Array to
access data
Ex:
1234
5678
9065
call Z order method to pass order For ex: pass 3
then output is
1396 to Access four corner of the z order
Read Moreoutput form to use z order technique.
z order technique is Show view of the Z corner to print the
z style.
Z order is Access the data in the two dimension Array to
access data
Ex:
1234
5678
9065
call Z order method to pass order For ex: pass 3
then output is
1396 to Access four corner of the z order
10 :: Which property is used to lock a textbox to enter data?
TextBox.Enabled = True;
This property is used to lock the text box to enter data.
Read MoreThis property is used to lock the text box to enter data.
11 :: How many number of events does the Timer controls?
2 events, one is disposed , second one is tick event
Read More13 :: How to split a column header in gridview using C#.net?
this can be done at client side, if u have a fixed format
by , creating a html table format in grid's "header
template" and in item template.
Read Moreby , creating a html table format in grid's "header
template" and in item template.
14 :: Where to use NEW keyword other than create instance?
Hiding of base class method (non abstract method) can be done just by giving an implementation in the derived class. The "new" keyword is not necessary. You can add the "new" keyword to prevent a warning message during compilation.
Read More15 :: Explain HOW TO NET FORMS THE WINDOWS?
Windows Forms: is the name given to the graphical
application programming interface (API) included as a part
of Microsoft .NET Framework, providing access to native
Microsoft Windows interface elements by wrapping the extant
Windows API in managed code.
Read Moreapplication programming interface (API) included as a part
of Microsoft .NET Framework, providing access to native
Microsoft Windows interface elements by wrapping the extant
Windows API in managed code.
16 :: Explain How to add resources during runtime?
Call the GetLocalResourceObject or GetGlobalResourceObject method to read specific resources from a global or local resource file
The GetGlobalResourceObject method takes the name of a resource class and the resource ID. The class name is based on the .resx file name. For example, the file WebResources.resx, and all associated localized files, are referenced by the class name WebResources.
The GetLocalResourceObject method takes a resource name representing a ResourceKey property.
Button1.Text = GetLocalResourceObject("Button1.Text").ToString();
Button2.Text = (String)GetGlobalResourceObject(
"WebResourcesGlobal", "Button2.Text");
A local default resource file stored in the special App_LocalResources folder is named according to the ASP.NET page. For example, if the following code is used in a Default.aspx page, the resource file must be named Default.aspx.resx. For this example, add a string resource to this file named Button1.Text with the value "Found Resources".
A global default resource file that is stored in the special App_GlobalResources folder is named WebResourcesGlobal.resx. Add a string resource named LogoUrl with the value "Found Resources".
Read MoreThe GetGlobalResourceObject method takes the name of a resource class and the resource ID. The class name is based on the .resx file name. For example, the file WebResources.resx, and all associated localized files, are referenced by the class name WebResources.
The GetLocalResourceObject method takes a resource name representing a ResourceKey property.
Button1.Text = GetLocalResourceObject("Button1.Text").ToString();
Button2.Text = (String)GetGlobalResourceObject(
"WebResourcesGlobal", "Button2.Text");
A local default resource file stored in the special App_LocalResources folder is named according to the ASP.NET page. For example, if the following code is used in a Default.aspx page, the resource file must be named Default.aspx.resx. For this example, add a string resource to this file named Button1.Text with the value "Found Resources".
A global default resource file that is stored in the special App_GlobalResources folder is named WebResourcesGlobal.resx. Add a string resource named LogoUrl with the value "Found Resources".
17 :: Write a program to create login form?
The following example demonstrates how to use a Login
control to provide a user interface to log on to a Web site
with sql server database. VB : Imports System.Data ,
Imports System.Data.SqlClient and Imports
System.Web.Configuration , C# : using System.Data; , using
System.Data.SqlClient; and using System.Web.Configuration;
1. xml file or web.config
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ConnectionASPX" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Northwi
nd.mdf;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
2. how-to-login-with-sql-server-c.aspx (Design Page)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="how-
to-login-with-sql-server-c.aspx.cs"
Inherits="how_to_login_with_sql_server_c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>how to login with sql server database</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Login ID="Login1" runat="server"
BackColor="#FFFBD6" BorderColor="#FFDFAD" BorderPadding="4"
BorderStyle="Solid" BorderWidth="1px" Font-
Names="Verdana" Font-Size="0.8em"
ForeColor="#333333"
OnAuthenticate="Login1_Authenticate" TextLayout="TextOnTop"
Width="293px"
Height="172px">
<TitleTextStyle BackColor="#990000" Font-
Bold="True" Font-Size="0.9em"
ForeColor="White" />
<InstructionTextStyle Font-Italic="True"
ForeColor="Black" />
<TextBoxStyle Font-Size="0.8em" />
<LoginButtonStyle BackColor="White"
BorderColor="#CC9966" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Verdana" Font-Size="0.8em"
ForeColor="#990000" />
</asp:Login>
</div>
</form>
</body>
</html>
3. how-to-login-with-sql-server-c.aspx.cs (Code Behind
C# Language)
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;
public partial class how_to_login_with_sql_server_c :
System.Web.UI.Page
{
protected void Login1_Authenticate(object sender,
AuthenticateEventArgs e)
{
string username = Login1.UserName;
string pwd = Login1.Password;
string strConn;
strConn = WebConfigurationManager.ConnectionStrings
["ConnectionASPX"].ConnectionString;
SqlConnection Conn = new SqlConnection(strConn);
Conn.Open();
string sqlUserName;
sqlUserName = "SELECT UserName,Password FROM
UserName ";
sqlUserName += " WHERE (UserName ='" + username
+ "')";
sqlUserName += " AND (Password ='" + pwd + "')";
SqlCommand com = new SqlCommand(sqlUserName, Conn);
string CurrentName;
CurrentName = (string)com.ExecuteScalar();
if (CurrentName != null)
{
Session["UserAuthentication"] = username;
Session.Timeout = 1;
Response.Redirect("how-to-StartPage.aspx");
}
else
{
Session["UserAuthentication"] = "";
}
}
}
Read Morecontrol to provide a user interface to log on to a Web site
with sql server database. VB : Imports System.Data ,
Imports System.Data.SqlClient and Imports
System.Web.Configuration , C# : using System.Data; , using
System.Data.SqlClient; and using System.Web.Configuration;
1. xml file or web.config
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ConnectionASPX" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Northwi
nd.mdf;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
2. how-to-login-with-sql-server-c.aspx (Design Page)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="how-
to-login-with-sql-server-c.aspx.cs"
Inherits="how_to_login_with_sql_server_c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>how to login with sql server database</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Login ID="Login1" runat="server"
BackColor="#FFFBD6" BorderColor="#FFDFAD" BorderPadding="4"
BorderStyle="Solid" BorderWidth="1px" Font-
Names="Verdana" Font-Size="0.8em"
ForeColor="#333333"
OnAuthenticate="Login1_Authenticate" TextLayout="TextOnTop"
Width="293px"
Height="172px">
<TitleTextStyle BackColor="#990000" Font-
Bold="True" Font-Size="0.9em"
ForeColor="White" />
<InstructionTextStyle Font-Italic="True"
ForeColor="Black" />
<TextBoxStyle Font-Size="0.8em" />
<LoginButtonStyle BackColor="White"
BorderColor="#CC9966" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Verdana" Font-Size="0.8em"
ForeColor="#990000" />
</asp:Login>
</div>
</form>
</body>
</html>
3. how-to-login-with-sql-server-c.aspx.cs (Code Behind
C# Language)
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;
public partial class how_to_login_with_sql_server_c :
System.Web.UI.Page
{
protected void Login1_Authenticate(object sender,
AuthenticateEventArgs e)
{
string username = Login1.UserName;
string pwd = Login1.Password;
string strConn;
strConn = WebConfigurationManager.ConnectionStrings
["ConnectionASPX"].ConnectionString;
SqlConnection Conn = new SqlConnection(strConn);
Conn.Open();
string sqlUserName;
sqlUserName = "SELECT UserName,Password FROM
UserName ";
sqlUserName += " WHERE (UserName ='" + username
+ "')";
sqlUserName += " AND (Password ='" + pwd + "')";
SqlCommand com = new SqlCommand(sqlUserName, Conn);
string CurrentName;
CurrentName = (string)com.ExecuteScalar();
if (CurrentName != null)
{
Session["UserAuthentication"] = username;
Session.Timeout = 1;
Response.Redirect("how-to-StartPage.aspx");
}
else
{
Session["UserAuthentication"] = "";
}
}
}
18 :: Explain something about crystal report in brief?
Crystal Reports provides broad data connectivity options
making it easy to access enterprise data and satisfy
end user information requirements.
if u want to use your own SQL commands use the query
generation in Crystal Reports
Read Moremaking it easy to access enterprise data and satisfy
end user information requirements.
if u want to use your own SQL commands use the query
generation in Crystal Reports
19 :: How to create a set up in vb.net for desktop application please say steps with examples?
1.Goto file<new project<select setup and deployment in the
template
2.Add your project by right click the project that u newly
created(In Solution Explorer)
3.Add Project ouput and localised resources by right
clicking the existing project in solution explorer
4.Finally build the project
(or)
Take a Setup project from Visual Studio Deployment
Projects. By default you will get.
File System on Target Machine
Different Editors in Setup project
1. File System on Target Machine.
2. Registry on Target Machine
3. File Types
4. User Interface
5. Custom Actions
6. Launch Conditions
Read Moretemplate
2.Add your project by right click the project that u newly
created(In Solution Explorer)
3.Add Project ouput and localised resources by right
clicking the existing project in solution explorer
4.Finally build the project
(or)
Take a Setup project from Visual Studio Deployment
Projects. By default you will get.
File System on Target Machine
Different Editors in Setup project
1. File System on Target Machine.
2. Registry on Target Machine
3. File Types
4. User Interface
5. Custom Actions
6. Launch Conditions
20 :: Suppose I have two combobox .. and i have some items in both combobox now i need to check the item in both combobox if same item is Present in both combobox i need to display that item in message box?
For inti As Integer = 0 To ComboBox1.Items.Count
For intj As Integer = 0 To ComboBox2.Items.Count
If ComboBox1.Items(inti).ToString =
ComboBox2.Items(intj).ToString Then
MessageBox.Show(ComboBox1.Items(inti))
End If
Next
Next
Read MoreFor intj As Integer = 0 To ComboBox2.Items.Count
If ComboBox1.Items(inti).ToString =
ComboBox2.Items(intj).ToString Then
MessageBox.Show(ComboBox1.Items(inti))
End If
Next
Next
21 :: Suppose I am implementing one windows form. I am inserting some values into ms access. In that table 5 columns there. But I want to insert three columns only. when I am clicking another button then other two values also insert into that table?
first time insetr five columns but two columns are empty
value thats null value when we click another button update
query is used insert remaining columns (where condition
filled columns value)
Read Morevalue thats null value when we click another button update
query is used insert remaining columns (where condition
filled columns value)