Run Validation On A WinForms UserControl?

May 8, 2009

I have an WinForms app that requires Name/Address data in lots of places, so I decided it would be a good idea to create a User Control. So far, so good. My problem is this: Let's say that my UserControl presents 2 text boxes (txtFName and txtLName) and txtLName is mandatory. What I want to do is put the validation code, e.g.: Code:If txtLName.Text.Length = 0 ThenMessagebox.Show("Enter a last name")End If

[Code]...

View 6 Replies


ADVERTISEMENT

.net - UserControl Closing Event In Winforms

Mar 4, 2010

I'm trying to save some layouts from DevExpress Grid Controls so that users can change the layouts and reload them in at a later use of the control.

My question is this for speed issues I am loading the control via a user control inside of a form. Now my problem is I am creating the control by adding an instance of the control to a panel control inside of a tabbed group control when the tab is made visible and then clearing the control when the control is hidden.

If ClaimsGridPanelControl.Visible = True Then
ClaimsGridPanelControl.Controls.Add(New RXClaimsGridControl(ClaimsBindingSource))
Else
ClaimsGridPanelControl.Controls.Clear()
End If

So inside of the RxClaimGridControl I need to call a SaveLayout method when I am clearing the control. But there is no event, at least that I can find, that triggers when a usercontrol is removed/closed/hidden.

My thoughts for handling the .Clear() would be to raise an event in the parent control and then to handle that event inside of the user control.

Is there some event that I am missing in regards to the removal/closing/hiding of a user control, or is there a better way to do this.

View 2 Replies

.net - WinForms UserControl Version Of Form.Closing

Apr 25, 2012

I've got an MDI form with child forms that I'd like to refactor to a single form with a tab control containing child controls, in order to move away from MDI clunkiness. When looking at converting the child forms into child controls (or usercontrols), I do see that I'd lose the FormClosing event, which some of the child forms use.

I can override Dispose to handle some of the functionality, but in some cases I'd like to cancel the closing event. Also, I'd like this event to be called before the control is closed even when the form it's on isn't closing, so wiring the control to the form's closing event isn't an option.

[Code]...

View 2 Replies

C# - Usercontrol Scaling When Added At Runtime In .Net, WinForms?

Apr 2, 2010

[URL]its a free hoster, so you have to wait 10 seconds.First here's the steps to replicate, then I'll explain what the problem is:

(1) Create a System.Windows.Forms.UserControl and add a button to the bottom-right hand corner. Leave the button anchor as default (top-left). Add some more buttons dotted around so that you can see that they scale correctly.

(2) Add the UserControl to a form in the construtor, after the InitializeComponent call.

(3) Run the form.

(4) Increase the form font size some way (eg click a form button).

All the controls within the usercontrol scale perfectly but the usercontrol itself doesn't. It's width and height are increased by way too much. Look at the margin now between the button at the bottom-right hand corner and the usercontrol.To correct the problem, the usercontrol must be added before the InitializeComponent call.If it wasn't possible for me to add the usercontrol before InitializeComponent, is there any way for me to correct the scaling?

View 2 Replies

DataBound UserControl And PropertyNameChanged Event In .net Winforms?

Oct 30, 2009

I have a UserControl, with a TextBox and a databound property - Value.Value can be any object such as a Color, Array, Font etc.Any time the text changes, the property Value is changed as long as it is valid.Looking at the msdn article: How to: Apply the PropertyNameChanged Pattern , it says I should use the PropertyNameChanged Event patternfrom the control side.Now, If I have DataSourceUpdateMode = OnValidate, then I don't even need to apply this pattern. If, say. my Value property is bound to a colour field in a business object, then after I type red, in the textbox and tab to another field, then any other fields on the form, that bind to the same colour field, are updated immediately.

View 1 Replies

Winforms UserControl Is Not Using The Inheritance Tree Have Created?

Jul 26, 2009

I am working on a wizard form framework that will allow me easily create wizard forms.I have a WizardForm form that has a panel on it. My plan is to dynamically load UserControls into this panel on the form.Each UserControl that is loaded onto the form panel must implement certain properties (allowNavigateNext, AllowNAvigate previous etc.). So I have created an interface to enforce that contract so that any custom user control can be used in the wizard as long as it implements that Interface. So far so good. created my first user control. I implemented the interface. All was good.I went to do the second user control and I realized that this second user control would have the EXACT SAME implementation of the interface as the first User Control. So...I thought...aha...duplicated code...how can I get rid of that.

View 3 Replies

ComboBox Force Validation -WinForms?

Dec 7, 2011

Is it possible to force a combobox to run it's validation event without moving the focus out of the ComboBox?

I need the event (or an event) to trigger when an item is selected with the mouse or an entry is typed into the combo box. I tried using SelectedValueChanged and SelectedIndexChanged however, these events do not fire if the user types a value that does not exist in the list source. I know I can change the DropDownStyle to DropDownList however, I still want the users to be able to type entries in the combobox (with auto complete).

View 3 Replies

Winforms - .NET Multiple Textboxes Validation?

Dec 1, 2010

validating a form with multiple text boxes? User would be informed what was the problematic field.The source of the form:

Private Sub btnNewUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewUser.Click
'If txtEmail.Text.Contains(" "c) Or Not(InStr(txtEmail.Text, "@")) Then
'txtEmail.Clear()
'ElseIf txtPassword.Text.Contains(" "c) Then

[code].....

View 2 Replies

C# - WinForms UserControl How Do I Stop The Control Receiving Focus?

Nov 7, 2011

I have a custom UserControl that contains just one TextBox. When I set the control to Enabled = False, the TextBox is disabled but the control is not (control still fires the Enter event).

How do I ensure that the UserControl will not receive focus?My Enabled Property Looks like this:

Private _Enabled As Boolean = True
Public Shadows Property Enabled As Boolean
Get
Return _Enabled
End Get

[Code]...

View 2 Replies

Winforms - TextBox Validation In .NET And Windows Forms?

Mar 5, 2009

I'm using the following code to validate the text entered by user. It works perfectly fine. But I want to add the backspace feature so as to allow the user to delete the wrongly entered number.I have tried a couple of things and they worked but before last digit (after the decimal point) i.e. it does not allows to delete after the number has been completely entered.number is being entered in the format: 12313213.45

What shall I do?Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress

[Code]...

View 7 Replies

.net - WinForms - Prevent UserControl's Resources Being Copied Into The Form's Local Resource?

Dec 29, 2009

I have a simple windows Forms application where in I have a usercontrol called "MyControl" derived from PictureBox.

In this MyControl, I have the following code :

Sub New()
MyBase.New()
Me.BackgroundImage = My.Resources.MyImage 'This is a project resource image
End Sub

Now when I drag and drop this MyControl into a form, I get the image and also those stuff. But the problem is that the BackgroundImage is being copied into the Form's local .resx file.So when I look into the form.designer file, I find the following :

Me.MyControl1.BackgroundImage = CType(resources.GetObject("MyControl1.BackgroundImage"), System.Drawing.Image)

This is a problem and also when I try to change the image in the control, it does not get reflected in the form's control instance.

View 3 Replies

Winforms - Usercontrol With Dockstyle Fill Not Correct Size During Form Load

May 25, 2011

My main form has two panels, left docked and right docked. The right side panel has two child panels with top dock and bottom dock settings. The usercontrol is added to the right side top panel. My usercontrol has a panel and a label. The panel is anchored on all 4 sides, the label is anchored on all except the bottom. At runtime I create this usercontrol and set it to dockstyle=fill and then I add it to my top right panel.

With everything set to "fill" I expect that when I add my usercontrol to the panel it will take on the appropriate width and height and pass that info to the child controls (labels) inside of my usercontrol. My problem is that this stretching of the size does not happen when I create my objects during the Load event on my usercontrol. Even though initializecomponent has ran for the usercontrol the panel inside of it (4 corners anchored) has not taken the x/y values of the available space. As a result my usercontrol shows up about 50% of the width I want.

[Code]...

View 1 Replies

C# :: Call Function From UserControl On ASPX From UserControl On MasterPage?

Jan 31, 2011

I have MainLayout.master that has UC_Menu.ascx on it. I have a page named Customer.aspx that uses MainLayout.master. Customer.aspx also contains a UserControl named UC_Details.ascx.How can I have UC_Menu.ascx call a function that is in UC_Details.ascx with this scenario?

View 3 Replies

UserControl Access To Public Properties In Another UserControl?

Jun 12, 2011

I have a Windows Form frmMain() holding seven more-or-less unrelated UserControls, ucFlopsy", "ucMopsy", "ucCottontail", etc...I say "more-or-less" because each of the seven UC has three similar public read/write properties:

IsLocked (a boolean indicating if the following two properties are "Locked")
IsLockedID (if IsLocked=True then IsLockedID is an integer)
IsLockedName (if IsLocked=True then IsLockedName is a string)

[code].....

View 1 Replies

.net - RaiseEvent From A UserControl That's Placed On A UserControl That's On A Form?

Jul 11, 2011

I have a Windows Form that contains a custom control container as a UserControl. For the sake of this question, this custom control container is called Dashboard. This container called Dashboard contains numerous other controls depending on their permissions. I need to raise events that are contained on these controls through the Dashboard control and over to the Windows Form.

How can I bubble up the event? I'm using VB.NET for this project, but can convert C# into VB.NET.Also, to complicate matters, the main Windows Form is a VB6 project. So, I'm using the InteropFormsToolkit to accomplish this.

View 1 Replies

Asp.net - Reference TextBox In One UserControl From Another UserControl

Jan 19, 2011

I have two UserControls on a MasterPage. DataEntryUC contains several TextBoxes and DropDownList. NavSaveUC contains navigation buttons. When the user clicks on a navigation button, I will be saving the data entered into DataEntryUC from the NavSaveUC UserControl.

I have a couple of tables in my DB that contain stored procedure names, control names, control types, SqlDbTypes, etc.... that correlate with DataEntryUC.

How do I reference a text box that is on DataEntryUC from NavSaveUC?

I have been working on the following code from NavSaveUC with no luck.

Dim MyControlName = "txtFirstName"
Dim MyControlType = "TextBox"
Dim MyStringValue as String

[Code]....

View 2 Replies

Setting Usercontrol Properties Within A Usercontrol

Mar 22, 2012

I have a usercontrol that has a main form and calls another form within the usercontrol to get some data from a database that allows the user to select some items from a CheckedListBox control on the sub form. I want to pass the selected items from the CheckedListBox back to the main form and display the results there. I have a public property called DBList of type List(of String) on the main user control. If I create a reference to the usercontrol form the second form within the usercontrol I get a new instance of a user control. All I want to do is set the property on the usercontrol and close the secondary form. How do I reference the usercontrol from the form within the usercontrol?

Code in UserControl:

Public Property DBItems() As List(Of String)
Get
Return DBItems

[Code]....

View 3 Replies

VS 2010 Load Data Into UserControl In UserControl.Load?

Sep 25, 2011

I just discovered the joys of UserControl's and I was wondering if it is possible to populate the usercontrol with data from a database in the UserControl's Form.Load event instead of the form the userControl is placed on. I feel it would make using the control a lot easier if it just populated itself without anymore code.I tried it with a ListView but it gave me a bunch of errors, so I didn't know if it had to be done a certain way or if it was just one of those things that doesn't work no matter what.

View 8 Replies

IDE :: Set Project Default For Winforms Projects S/ Default Modifier For Controls Added To Winforms Is Private

May 28, 2010

Is it possible to set a project default for VB.NET winforms projects so that the default Modifier for controls added to winforms is Private (not Friend)?I know there's a "modifiers" property in the properties window so I can set it for each individual control however I would like to change the project so from now on myself and other developers have to specifically decide to change from friend to private. (Which I would strongly discourage them from doing).I believe there is no way of doing this, but on another forum a while ago someone mentioned it would be possible with an add-in (but didn't name the add-in or where to get it).

View 1 Replies

Access Usercontrol In VB?

Aug 29, 2009

I have created a usercontrol named note. in the note usercontrol in contains 6 labels. now i want to access the usercontrol at runtime. it means that, when the right button is press, the note usercontrol is appear, when it pressed again it appear again beside the previous usercontrol. how can i access it like when user is click at one of the labels, that labels backcolor change to other color. it is means that a label that has been clicked is the selected label. and we can change the properties of that selected label.

View 2 Replies

Add A Usercontrol To A Panel?

Aug 12, 2010

I want to add a usercontrol to a panel. My code does not work: Panel1.Controls.Add(uc1)

View 1 Replies

Adding Usercontrol Twice In Asp.net?

Sep 30, 2010

I got a user control that has a few links, one of them is "add article". It's placed on top of the article and bottom of it. When the user clicks on it, the text changes to 'article added'.

But the text only gets changed for one of the links which has been clicked on. How can I make it so that both text changes no matter which one gets clicked?

View 1 Replies

Asp.net - UserControl And Inner Properties?

Jul 30, 2010

I am trying to develop a control that'll allow the developer to populate a collection through markup (e.g. Properties decorated with the attribute PersistenceMode(PersistenceMode.InnerProperty). I have an example from Brian Chavez that more or less does what I want but I want to have the control inherit from UserControl and not Control.Here is the code I have in vb.net:

AggregateFeeds.ascx.vb
Imports Microsoft.VisualBasic
<ParseChildren(True)>
<PersistChildren(False)>
Public Class AggregateFeeds

[Code]...

As it is now when I try to compile I get a compiler error that simply says object instance not set to an instance of an object on the line above. If I take it out, the page loads just fine and the Settings object reflects the values in the markup. Why am I having trouble getting the collection to populate correctly?

View 2 Replies

Convert UserControl To Dll?

May 17, 2012

How to convert UserControl.vb to dll? I'am using Microsoft Visual Studio 2010 Professional

View 2 Replies

Converting UserControl From C# To VB

Apr 18, 2012

I downloaded the next project from here:

[URL]

Now the project itself was built in C #, but the interesting part of me is "Toolbar.cs".

There is a way to replace the "Toolbar.cs" from C#, to VB? Or i must convert all the project? (Unfortunately, I do not know how)

I just want to build the part that I need(UserControl - "Toolbar.cs") in VB, and the rest can stay in C #, it does not matter to me.

View 7 Replies

CustomPaging In UserControl?

Jun 1, 2009

I created Custom Paging User Control for a GridView. The Custom Control I am using at the top of GridView and Bottom of GridView. If I am clicking Next on top of Grid View, it is not effecting in the bottom.

View 1 Replies

How To Add UserControl In Toolbox

Feb 19, 2009

I created a UserControl in a ClassLibrary project and then built it to generate the .dll file. I then want to create a new project and i added this .dll as a reference to my new project. but how do I add the UserControl in the class to my Toolbox? I'm using Visual Basic 2005 Express Edition.

View 2 Replies

How To Use .net Usercontrol From A 64 Bit Library

Jun 3, 2010

I am running through an issue for which I am unable to find a solution.My goal is to:1- compile a x64 .NET library (vb) which has a simple User Control 2- Use this dll in a .NET WinForm application targeted to x64 CPU ONLY.

I have been able to do the first step, but now I am unable to add the library into the VisualStudio Toolbox. With our previous x86 version we had just to right click to VS toolbox, click on "Choose items...", then brows to the needed x86 assembly. If we do the same selecting a x64 lib (of course I am running vs on a 64 bit OS), we get the following message "[DLL PATH] is not a Microsoft .NET module."

View 1 Replies

How To Use Usercontrol On A C# Page

May 26, 2010

I've created a usercontrol in VB that handles paging more efficiently than the DataPager (at least for very large datasets). I'd like to use it in a C# project, but I've been having trouble getting it to work.I've tried simply adding PagingControl.ascx to the C# project, but when I do that the markup and VB code behind don't seem to see each other. --Is this a namespace issue?I've tried adding the PagingControl.ascx to its own VB project, then adding that project to the C# project's solution, as well as a reference. --That almost works. I can register the PagingControl usercontrol in the markup. I can access the usercontrol's properties in the code behind, but any property that involves the UI of the usercontrol fails.

Its seems as if the usercontrol's form hasn't had a chance to load by the time the C# page's Page_Load event handler fires. --Maybe this is an "order of operations" problem? At what point in the C# page's lifetime should a usercontrol's form be loaded?

View 1 Replies

Programmatically Use A UserControl?

Feb 3, 2011

Have actually managed to create a UserControl complete with buttons, windows media player ... Right-Clicking in the toolbox I browsed to the dll and that brought the control into the toolbox successfully as VideoSourceControl.I can drag/drop this control onto the form and it is fine, buttons etc looking good. Now I want to create it programmatically - I actually want to refer to an array of them.On the form load I have

Public mySources() as SourceVideoControl and I get an error saying that 'SourceVideoControl is not defined'The dll that I loaded was called VideoMixerControl.dll?

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved