:: Home

  login:         
  passwords:  

WPF FAQs

WPF General Questions
Concepts Element Tree
Concepts Dependency Property
Concepts Attached Property
Concepts Routed Events
Concepts Resources.
Concepts Animation
Concepts Freezable Object
Concepts Input and Commands.
Concepts Layouts
XAML Inline Styles and Templates
XAML XML Namespaces
XAML Code Behind
XAML Custom Class
XAML Type Converters
Content Model ItemControl
Content Model HeaderedItemsControl
Content Model HeaderedContentControl
Content Model Content Control
Content Model Decorator Content Model
Content Model Panel Content Model
Documents Serialization and Storage
Documents Annotations
Documents Flow Content
Documents Printing
Graphics and Multimedia Rendering Graphics
Graphics and Multimedia Animation and Timing
Graphics and Multimedia 2D Graphics
Graphics and Multimedia 3D Graphics
Graphics and Multimedia Visual Layer
Control Customization Adorners
Control Customization Stylable controls
Control Customization ControlTemplates
Data Data Binding
Data DragandDrop
Data Serialization
Globalization and Localization Attributes
Globalization and Localization Comments
Globalization and Localization Globalization Struc
Application and Deployment ClickOnce
Application and Deployment Frame
Application and Deployment Page
Application and Deployment Navigation
Application and Deployment Setup
Application and Deployment Window
Interoperability Message Loops Between
Interoperability Win32 in WPF
Interoperability WPF in Win32
Interoperability Windows Forms and WPF
Security Trusted Security
Security Partial Trust Security
Tools Microsoft Expression Blend
Tools ZAM3D
Tools XAMLPAD
Controls ToolTip
Controls TextBlock
Controls TabControl
Controls ProgressBar
Controls PrintDialog
Controls Popup
Controls TextBox
Controls Canvas
Controls ComboBox
Controls ListBox
Controls StatusBar
Controls ToolBar
Controls Context Menu
Controls Expander
Controls DocumentViewer
Controls FlowDocumentReader
Controls GroupBox
Controls GridSplitter
Controls Image
Controls Menu
Controls ScrollBar
Controls Slider
Controls RichTextBox
Controls Border
Controls Buttons

SilverLight Interview Qs

SAP Interview Questions

Oracle Interview Questions

PHP Interview Questions

Ajax Interview Questions

IIS 7.0

OOP Interview Questions

Ruby Interview Questions

Sql Server Interview Questions

Winforms Interview Questions

SharePoint 2007 Questions

Microsoft Crm Questions

Controls TextBox Interview Questions & FAQs

Questions and answers for Controls TextBox.

61. Controls TextBox

    61.1 How do I format numbers, dates and currencies in a TextBox ?
    61.2 How do I make a TextBox use all upper-case (or lower-case) characters ?
    61.3 How do I support browsing for a text file and reading it into a TextBox?

61.1 How do I format numbers, dates and currencies in a TextBox ?

Each type has a "ToString" method that can be used to perform formatting. Also, you can use the "String.Format()" method to format things as well. To format dates, use the ToString member of 'DateTime'. You may want to use the "InvariantInfo" settings to get culture-independent strings.

C#]

float f = 444.4444f;
textBox1.Text = f.ToString( "c2" );

//or

textBox1.Text = String.Format( "{0:c2}", f );

61.2 How do I make a TextBox use all upper-case (or lower-case) characters ?

Use the CharacterCasing property of the TextBox.

[C#]

textBox1.CharacterCasing = CharacterCasing.Upper;
textBox2.CharacterCasing = CharacterCasing.Lower;


61.3 How do I support browsing for a text file and reading it into a TextBox?

You can use the OpenFile Dialog to implement this functionality.

[C#]

using System.Text;
using System.IO;

private void button1_Click( object sender, EventArgs e )
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Open text file" ;
dlg.InitialDirectory = @"c:\" ;
dlg.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;

if ( dlg.ShowDialog() == DialogResult.OK )
{
StreamReader sr = File.OpenText( dlg.FileName );
string s = sr.ReadLine();
StringBuilder sb = new StringBuilder();
while ( s != null )

{
sb.Append(s);
s = sr.ReadLine();
}
sr.Close();
textBox1.Text = sb.ToString();
}
}

bottom user control
::  Home :: Services ::  Prices ::  Request Quote
Copyright 2007, Megasolutions Ltd