![]() |
Desktop Development »
Miscellaneous »
Windows Forms
Intermediate
Multi-line InputBox control - MC++By Nishant SivakumarA .NET port of my MFC CFrameWnd derived InputBox class, written using MC++ |
C++/CLI, C#, VC7.NET 1.0, Win2K, WinXP, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

Just add a reference to InputBox.dll in your project. The class is
part of the namespace CodeProject.WinForms. So you might want to add
using CodeProject.WinForms on top of your source files. Of course that is if
you are using C#. For an MC++ app you need to put using namespace
CodeProject.Winforms on top of your source files.
InputBox(); - This creates a normal InputBox with a single
Input Line
InputBox(bool); - Depending on the bool you pass, this
overload will create a multi-line InputBox if you pass true and a single
line InputBox if you pass false
Example:-
InputBox m_ib = new InputBox(); InputBox m_multi_ib = new InputBox(true);
This has two overloads.
String* Show(String* prompt);
String* Show(String* prompt, String* title);
prompt - This is the prompt text that will appear in the
InputBox. It's a Label control and thus it will word wrap.
title - This is the window title of the InputBox
Return Value
The String that was entered is returned, if the OK button was clicked. If the Cancel button was clicked an empty string is returned.
InputBox m_ib = new InputBox(true); this.textBox2.Text = m_ib.Show("Enter your address please.", "Your address");
// InputBox.h
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Drawing;
using namespace System::Windows::Forms;
namespace CodeProject
{
namespace WinForms
{
public __gc class InputBox
{
private:
Form* InputForm;
TextBox* InputText;
Label* PromptText;
Button* BtnOk;
Button* BtnCancel;
bool m_multiline;
void InitializeComponent();
String* Show();
void BtnOk_Click(Object* sender,
EventArgs* e);
void BtnCancel_Click(Object* sender,
EventArgs* e);
public:
InputBox();
InputBox(bool);
String* Show(String* prompt);
String* Show(String* prompt, String* title);
};
}
}
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 7 Jun 2002 Editor: Nishant Sivakumar |
Copyright 2002 by Nishant Sivakumar Everything else Copyright © CodeProject, 1999-2009 Web17 | Advertise on the Code Project |