Click here to Skip to main content
15,914,111 members
Articles / Programming Languages / Visual Basic
Article

VB.NET User Control: Validate Empty Textbox with Image and Create and Dynamic Insert Query

Rate me:
Please Sign up or sign in to vote.
1.58/5 (5 votes)
28 Aug 20063 min read 47.3K   1.3K   11   3
Validate Empty Textbox with Image and Create and Dynamic Insert Query

Sample Image - TextBox_Personalizado.jpg

Contents



-Introduction
-Background
-Using the Code
-Conclusion
-Licensing and Limitation of Liability

Introduction

This User controls uses the following simple controls:textbox , label, button, image (Picture Box).

The purpose of these controls in my case is find the simple way to made dynamic insert queries, I pretend develop for delete query and update query.

The TextBoxControl user control permits any value but when receive an empty value display an image standard for error and notifies the empty field, also you can made a simple relation with ButtonsControl control this relation permits that the TextBoxControl control will be read it by the ButtonsControl.

Background

When you add the TextBoxControl to the form, you can add any as you need and after put into your form the ButtonsControl and configure both.

IMPORTANT: The ButtonsControl Control doesn't make a connection only create an INSERT string and display in message box if you had enable to True the property ModoTest, if you change to False the control will verify your Database Connection and will insert into the table assigned.

UPGRADE 30-AGO-06: Now you can create insert querys and verify that the regitry that you're triying to insert is not repeat in your data table, also is implemented a delete button, just write the TextBoxControl name in the PrimaryKey property field in your ButtonsControl .


Using the Code

1. Download the DLL file and, after unzipping, place it in an appropriate folder of your choosing.
2. In the Visual Studio Toolbox, right click in the General Controls tab to open a popup menu. (A form must be open for the control tabs to show in the Toolbox.) Click on the Add/Remove Items menu item.
3. In the Customize Toolbox dialog box, click on the Browse button to open the DLL file.
4. Click the OK button.

How configure these controls?

TextBoxControl

Property

Type

Description

LabelName

String

Get/Set the Label Name

TextBoxName

String

Get/Set the Textbox Name

TextBoxValue

String

Get/Set the Textbox Value

LabelValue

String

Get/Set the Label Value

ImageEmptyField

System.Drawing.Image

Get/Set the Validation Image

TextboxBackColor

System.Drawing.Color

Get/Set the Textbox Color

TextBoxReadOnly

Boolean

Get/Set the Textbox ReadOnly

ControlAssociated

String

Get/Set the Name of ButtonsControl Associated

DBField

String

Get/Set the Database Field


ButtonsControl

Property

Type

Description

ConnectionString

String

Get/Set the Connection String (not implemented)

DBTable

String

Get/Set the Database Table

TestMode

Boolean

Get/Set the Control Mode

PrimaryKey

String

Get/Set the Table Primary Key


Conclusion

With TextBoxControl control and ButtonsControl control, I can now create records in my data base quickly. I hope you find it useful and if you want to contribute contact me to make this control more robust and flexible for many tasks.

Licensing and Limitation of Liability

You may use all code offered in this article any way you choose without restriction.

Under no circumstances, and under no legal theory, tort, contract, or otherwise, will Roberto Cervantes (hereafter referred to as "software author") or his licensors, be liable to the user of the Double Text library and all code offered in this article (hereafter referred to collectively as "article code") for any damages, including any lost profits, lost data, or other indirect, special, incidental, or consequential damages, arising out of the use or inability to use the article code, and data or information supplied, even if the software author, his licensors, or authorized dealer have been advised of the possibility of such damages, or for any claim by any other party.


License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer
Mexico Mexico
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Global Analyser3-Nov-10 9:32
Global Analyser3-Nov-10 9:32 
GeneralProperty Names Pin
Fabse_net28-Aug-06 20:09
Fabse_net28-Aug-06 20:09 
AnswerRe: Property Names Pin
Roberto Cervantes Rivero28-Aug-06 20:41
Roberto Cervantes Rivero28-Aug-06 20:41 
You're right I wrote my code in spanish because is my first language, but the next release will be in english. Thanks. If you had comments or suggestions about these controls I really appreciate.Cool | :cool:

Rob.;)

"Un buen sistema debe de ser seguro y flexible, pero ni tan seguro como para no poderlo adecuar y ni tan flexible como para que cualquier individuo lo pueda modificar."

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.