Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

.Net Windows Controls Interview Questions and Answers for Freshers and Experience Part-2

Be First!

windows7. How will you pick a color from the ColorDialog box?
To pick a color from the color dialog box, you need to create an instance of the ColorDialog box and invoke to the ShowDialog() method. The code to display the color dialog box and set the BackColor property of the Label control similar to the color selected in the color dialog box control is:
private

void
button1_Click(
object
sender, EventArgs e)
{

if
(colorDialog1.ShowDialog() != DialogResult.Cancel)
{
label1.Text =
“Here’s my new color!”
;
label1.BackColor = colorDialog1.Color;
}
}

8. How can you get or set the time between Timer ticks?
There is an Interval property, which is responsible to get and set the time in milliseconds.

9. How can you programmatically position the cursor on a given line or on a character in the RichTextBoxcontrol in C#?
The RichTextBox control contains the Lines array property, which displays one item of an array in a separate line. Each line entry has a Length property, which can be used to accurately position the cursor at a character, as shown in the following code snippet:

private void GoToLineAndColumn(RichTextBox RTB,
int
Line,
int

Column
)
{

int
offset =
0
;

for
(
int
i =
0
; i < Line –
1
&& i < RTB.Lines.Length; i++)
{
offset += RTB.Lines[i].Length +
1
;
}
RTB.Focus();
RTB.
Select
(offset +
Column
,
0
);
}

10. What is the difference between the WindowsDefaultLocation and WindowsDefaultBounds properties?
The WindowsDefaultLocation property makes the form to start up at a location selected by the operating system, but with internally specified size. The WindowsDefaultBounds property delegates both size and starting position choices to the operating system.

11. Where does an ImageList control appear when you add it at the design time?
The ImageList control is a component; therefore, it appears in the component tray at the design time.

12. How can you programmattically prevent a Combobox from dropping, in .NET 4.0?
To avoid dropping of a Combobox, you need to override the WndProc() method and ignore WM_LBUTTONDOWNand WM_LBUTTONDBLCLK events.

(47)

Previous
Next

Leave a Reply