Hi, I have a property page for my user control that has a text box and a button on it, when the user enters text into the text box and clicks the button i want a new label to appear on the user control but im unsure of how to do this, And i dont want to have to add loads of blank labels as that is rather impractical and would take up unecessary memory.
If anyone could help i would be most appreciated
Kind Regards
Devon
8 6393
Hi, I have a property page for my user control that has a text box and a button on it, when the user enters text into the text box and clicks the button i want a new label to appear on the user control but im unsure of how to do this, And i dont want to have to add loads of blank labels as that is rather impractical and would take up unecessary memory.
If anyone could help i would be most appreciated
Kind Regards
Devon
Not sure if this will work...ive never tried creating a control
From code...this might might be incorect...if it doesnt work...most likely the "New lbl" line needs to be changed slightly - If Textbox.text = "" =false then
-
New lbl as label
-
lbl.position.x = 'Your positioning value
-
lbl.position.y = 'your positioning value
-
lbl.text = textbox.text
-
End if
Not sure if this will work...ive never tried creating a control
From code...this might might be incorect...if it doesnt work...most likely the "New lbl" line needs to be changed slightly - If Textbox.text = "" =false then
-
New lbl as label
-
lbl.position.x = 'Your positioning value
-
lbl.position.y = 'your positioning value
-
lbl.text = textbox.text
-
End if
Apologies i should mentions that this is for VB6, VB6 doesnt have the .position methods, i have tried -
Dim lbl As Label
-
lbl.Top = 100
-
lbl.Left = 100
-
lbl.Caption = TextBox.Text
-
lbl.Visible = True
-
but all i get is an error saying
"Object Variable or With Block Variable Not Set"
Hope this helps you to help me
Kind Regards
Devon
Could you tell be where exactly...the debugger stops on the code...
also change dim lbl as labale to dim xlbl as new label
lbl by itself might cause error.....try xlbl
Could you tell be where exactly...the debugger stops on the code...
also change dim lbl as labale to dim xlbl as new label
lbl by itself might cause error.....try xlbl
Ok, The subroutine im using on the UserControl is this -
Public Sub AddItem(strTemp As String)
-
Dim lbl As New Label
-
lbl.Top = 100
-
lbl.Left = 100
-
lbl.Caption = strTemp
-
lbl.Visible = True
-
End Sub
-
And on the Property page that is assigned to to the user control im using this -
Private Sub Command1_Click()
-
frmMain.WindowsTaskBox1.AddItem "TESTING"
-
End Sub
-
But im getting the error message when Command1_Click( ) is called.
"An Instance of frmMain cannot be created as its designer window is still open"
Apologies in advance, this is my first user control so still getting used to alot of the commands and such
And when i put WindowsTaskBox1 .Additem "TESTING" in the frmMain_Load() Method i get.
"Invalid Use of New Keyword" referring to "Dim lbl As New Label"
Kind Regards
Devon
Can no-one help me in this matter? Adding a label to a usercontrol during design time via the UserControl property page? if anyone can help id be most appreciated.
Example. When you highlight your user control that has been placed on your form, and click "Custom.." in your properties window, you get the properties window that you have assigned (Custom or VB built in) I have a text box and a command button, so when the user clicks the command button it automatically adds a label to the user control whilst still in design mode.
Kind Regards
Devon
Devonknows:
Here's some simple code for VB6 to create and place a new label. -
' General declarations:
-
' Create a new control to use as a label
-
Private MyNewLabel As Control
-
' Create a variable that we will use to make sure no two labels have the same name
-
Dim LabelCount as Integer
-
-
' A buttons' click event:
-
Private Sub Command1_Click()
-
-
' The following function is adding a new label to the form this code is on. The functions' parameters are as follows: Add( The type of control, The control's new name). We add the LabelCount variable to the end of it in order to make sure we have no controls with duplicate names.
-
Set MyNewLabel = Me.Controls.Add("vb.label", "MyNewLabel" & LabelCount)
-
-
' You MUST set visible to true if you want the new control to be visible
-
MyNewLabel.Visible = True
-
' Set how far the label is from the left
-
MyNewLabel.Left = 100
-
' Set how far the label is from the top
-
MyNewLabel.Right = 100
-
' Finally, set the caption of the label
-
MyNewLabel.Caption = "This is a new label!"
-
-
' Increment the LabelCount variable up by one
-
LabelCount = LabelCount + 1
-
-
' End our sub
-
End Sub
-
I hope this helps, I registered just to post this, as I only learned how to do this a month ago.
See ya,
Kai
Thanks kai
Knew we where missing something
Thanks kai
Knew we where missing something
When i add this to the property page for the user control, and then access the property page when i click Custom on the properties for my user control i get
'Method or Data Member not Found' and it highlights 'Me.Controls.Ad d.
im not sure if i mentioned earlier that i want the control to add during design time, for example the toolbar control, when you click add button, the toolbar control on the form automatically adds a button when you click ok/apply
ive looked at the code behind the toolbars and stuff and ive found that it creates like a class for a button, i was jus wondering if i need to do the same with a label, and if i created a label class, what information would i need in it. and how would i get it to add an instance of it to the user control on my form.Unfortunet ly ive looked everywere i can think of to find information on this but cant seem to find any information. So anyone that has created a custom toolbar control, or a status bar control or anything along them lines, any helped would be appreciated
Kind Regards
Devon
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bil Muh |
last post by:
Esteemede Developers,
I would like to Thank All of You in advance for your sincere guidances.
I am developing a software using Visual C++ .NET Standard Edition with
Windows Form (.NET) template.
Briefly
--------------------------------------------------------------------------------------------
I need to create dynamically some controls on the forms, and display these
|
by: DC Gringo |
last post by:
I'm trying to use a label control to show the # of records in my datagrid
and think I'm stuck on something simple...please help:
Error is: Name 'myDataSet1' is not declared.
FYI, it works fine if I use an integer value like "100" rather than
myDataSet1.Tables("CommunitiesT1")
-----MY LABEL CONTROL------
|
by: Ed West |
last post by:
Hello,
I have a simple form with some input boxes. After validation if one
fails, then I would like to at the top of the page say something like
"The following fields in red are required" and then change the label in
front of the textbox or dropdown list to red... is this possible with
asp.net? It seems you can only put a RequiredFieldValidator on the
page, and if it fails validation then that text is displayed... ?
Thanks
|
by: Quentin Huo |
last post by:
Hi:
I have a user control and I want to dynamically create a Label control and
TextBox control when the button "add more author name" is clicked.
I did like this:
1. there is a "PlaceHolder" control "ph" in the user control;
2. create a Label control and TextBox control when in the "add" button
|
by: Patrick.O.Ige |
last post by:
I created a USERCONTROL and i want to call a LABEL from an ASPX page.
The USERCONTROL is in the ASPX page
I have the label :-
Label lblstr = new Label();
And displaying using:-
lblstrp.Text=lblstr.Text;
<asp:label id="lblstrp" BorderColor="#ff3333" BorderStyle="Dashed"
BorderWidth="3" ForeColor="#0033cc"
Font-Size="25" Runat="server" Width="55%" BackColor="#ffff00"></asp:label>
| |
by: nospamjac |
last post by:
Hi,
Is there a way to update the text of an asp:label on a webform without
refreshing the entire page? What is called by button clicks and other
events that refresh a webform control?
See the example WebForm1.aspx and WebForm1.aspx.cs code below:
WebForm1.aspx
=======================================================
|
by: lupina |
last post by:
Hi
I'm making web user control in ASP .NET 2.0 (TextBox + Button). It works
allright, but I need to add property and event to it, that would be visible
in VS Designer.
With property I havn't any troubles:
using System.ComponentModel;
private string message;
|
by: Mich |
last post by:
Hi,
i'm building an web application for anonymous users. They can take a look in
the website, nothing more. In order to perform other actions, the anonymous
user must be logged. So i create an aspx page with the CreateUserWizard
control. The user can fill his username, password etc ....
My problem is: when an user fills everything and clicks on button "create an
account", nothing happens (no error, but no user account created).
I...
|
by: Jim in Arizona |
last post by:
On one page I have a datalist where a message is bound to a label.
On another page I have the datalist which allows for the insert of new
message as well as being able to edit those messages. The editing
(EditItemTemplate) has a textbox that loads the message into its text
property.
The problem I'm running into is working with vbCrLf and <brinterchangeably
between the textbox on the admin page and the label on the general message
page. I...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |