hw3 Cap 406
hw3 Cap 406
Course Instructor: ______ MR Rohit Ohri____ Course Tutor (if applicable): MR Rohit Ohri_
namespace E
{
using D;
class Program
{
static void Main()
{
// Can access CClass type directly from A.B.C.
CClass var1 = new CClass();
// Output.
Console.WriteLine(var1);
Console.WriteLine(var2);
Console.WriteLine(var3);
}
}
}
namespace A
{
namespace B
{
namespace C
{
public class CClass
{
}
}
}
}
namespace D
{
public class DClass
{
}
}
namespace F
{
public class FClass
{
}
}
Output:
A.B.C.CClass
D.DClass
F.FClass
Q2. What are properties and methods of List Box. Using example
explain how we use them?
properties of listbox
q MultiExtended:
Multiple items can be
selected and the user
can use the Ctrl, Shift
and arrows keys to
make selections.
Setting this property to
true will cause the
Sorted Read/Write ListBox to sort the items
it contains
alphabetically.
Text Read/Write We've seen Text
properties on a number
of controls, but this one
works very differently
than any we've seen so
far. If you set the Text
property of the list box
control, it searches for
an item that matches
the text, and selects it.
If you get the Text
property, the value
returned is the first
selected item in the list.
This property cannot be
used if the
SelectionMode is None.
(CheckedListBox only)
This property is a
collection, which
CheckedIndicies Read-only contains all indexes in
the CheckedListBox that
is a checked or
indeterminate state.
(CheckedListBox only)
This is a collection of all
the items in a
CheckedItems Read-only CheckedListBox that are
in a checked or
indeterminate state.
(CheckedListBox only) If
this property is true, an
CheckOnClick Read/Write item will change its
state whenever the user
clicks it.
(CheckedListBox only)
You can choose between
ThreeDCheckBoxes Read/Write Checkboxes that are flat
or normal by setting
this property.
Listbox methods
Name Description
ClearSelected Clears all selections in the ListBox,
FindString Finds the first string in the ListBox
beginning with a string you specify
for example FindString("a") will find
the first string in the ListBox
beginning with 'a'
Like FindString but the entire string
FindStringExact
must be matched
Returns a value that indicates
GetSelected
whether an item is selected
Sets or clears the selection of an
SetSelected
item
ToString Returns the currently selected item
(CheckedListBox only) Returns a
GetItemChecked value indicating if an item is
checked or not
(CheckedListBox only) Returns a
GetItemCheckState value indicating the check state of
an item
(CheckedListBox only) Sets the
SetItemChecked
item specified to achecked state.
(CheckedListBox only) Sets the
SetItemCheckState
check state of an item
Q3. Write detailed Program. And Steps to create Message Box that
gives a confirmation message after checking user name and pass word
authentication from a user?
Q4. What are properties of Date Time Picker. To which library they
belong and program to use them?
Ans
Properties Comments
Format A DateTimePickerFormat value that specifies if the forma
MaxDateTime A read-only DateTime object that indicates the maximum d
MinDateTime A read-only DateTime object that indicates the minimum d
Text A string object that represents the selected date.
Value A DateTime object that represents the selected date.
using System
System.Collections.Generic
System.ComponentModel
System.Drawing
System.Text
System.Windows.Forms
Public Class Form1
Inherits Form
End Sub
Private timePicker As DateTimePicker
End Sub
<STAThread()> _
Shared Sub Main()
Application.EnableVisualStyles()
Application.Run(New Form1())
End Sub
End Class
Answer
if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
Console.WriteLine(saveFileDialog1.FileName);
}
Q7. How do you use File Input Output Dialogue Box? What is the
purpose of System.IO. Writ a prg. And give its use.
Q8. What is color Dialogue Box. How do we use it?
Answer Program states that in one form if we want to place one
button, while clicking on the button next form is appear with change
color and having a display button like change color in a new window
button, if we click new window button we will take color dialog box
along with button which looks like button (…) along with the textbox. If
we click on (…)button color dialog box is appear and if we choose color
on that dialog box the back color of the textbox will be filled like that.
Open new project and create a Form1 with one button having text
property click to change color as shown below.
Place a code on the double click on the button event.
Next create another page with the help of add existing item,as shown
below:
As soon as we click on the button(…)we can see a color dialog box as
shown below.
FIG 1