Refer To All Of One Type Of Control?
Jul 8, 2009Refer to all of one type of control?
View 2 RepliesRefer to all of one type of control?
View 2 RepliesI have code like this which loads a control from an .ascx file, calls some methods of the control, then renders it:
Option Explicit Off
Sub renderMyControl(p As Page)
Dim ctrl as Object = p.LoadControl("path/to/myControl.ascx")
' ... do stuff with ctrl ...
[Code]...
This code only works because Explicit is off. I would like to use CType to convert the control to its "strong type" (and get rid of Option Explicit Off) but I don't know how to add a reference to the type. How can I do this?
This was explained in a recent thread - but I can't find it again :-( Why won't the following work? I am trying to set the bounds on 9 buttons - Button11 to Button19. All these buttons are already added in design time. qli() is a rectangle array.
[Code]...
Im working on a project and just wanted to know to make a control refer to itself?I know that by using the word "Me", the system refers to the form but how about the control. I know that i can simply name the control (e.g. txtSurname.Clear) but if i was to use the code on multiple controls it would save alot of time if the control could simply refer to itself!
View 7 RepliesI have a problem with using a script that adds a NiceEdit toolbar to a text area when that text area is within an Ajax tab.I want to know if I should refer to it in a different way than just the ID.I mean the ID of that text area, I tried to take the text area outside the Tab Container, it works, but when I return it, it simply doesn't.[code]
View 1 RepliesSuppose I have a label control on a windows form called "UserName". How can I refer to that label programmatically using the label name? For example I can do:
For each ctrl as Control in TabPage.Controls
If ctrl.Name = "UserName" Then
' Do something
End If
Next
This seems quite inefficient. I would like to do something like: TabPage.Controls("UserName").Text = "Something" I did some googling but couldn't find a satisfactory answer. Most suggested looping, some said .NET 2005 doesn't support direct refenece using string name, and FindControl method was asp.net only...
[Code]....
I'm an Access/VBA programmer new to vb.net. In Access I can do this using the controls collection of form, but I can't figure out how or even if I can do it with vb.net.
I want to change this:
'tcpWeek(x) is a tab control page
My.Forms.frmBookMain.tcpWeek1.Text = "Mytext1"
My.Forms.frmBookMain.tcpWeek2.Text = "Mytext2"
[Code].....
If I have a TextBox control with the Name Property = Textbox1, is there a way to use a variable for part of the name - like this:
Dim i as String = "1"
"TextBox" & i & ".Text" = "Hello"
I would like to refer to a control but i do not know its number but i do know that it is a ComboBox. I was told to use this
Me.Controls("ComboBox" & 1 + i).Text
Which would get the text property of the i +1 ComboBox. However when run this I get an ullReferenceException was unhandled error. What an I doing wrong?
In VBA from Access 2003 I was able to employ the following :Form.Controls(" in here I am able to use a string variable holding the name of the control I want to reference ").property= etc.Is this kind of thing possible in VB .netI have a listview control to which I am adding 'errors' and the tag property of each item hold a string that is the name of the control I want to set the focus to when they double click on the listview item. So I want to do something like this :<listviewitem.tag>.focus()and have the string interpreted as a control name.
View 5 RepliesHow can I refer to the control while I am inside a control's method in VB.NET?For example, I want in a textbox to show a message box with that textbox's text every time the text changes. The code would be something like:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
[code].....
I am trying to make it so when I use Me.Controls("Timer1") for example I can access specific commands for a timer such as Stop() Start(), I tried CType() and typed in "Timer" as the type but it says the control type can't be converted to the "Timer" type.
View 11 RepliesIf I create a list for a TextBox:
[Code]....
I am able to only add controls that are of type TextBox. My question to you is, can I create a List to hold more than one control type or do I have to create a list for each control type?
I want to add a control in winforms that drops like combo box but can show data like datagridview. I have seen this control in an application but not able to find a way how to do it. (Pic attached)
View 2 RepliesPublic Shared Function IsType(ctrl As Control, ByVal thisType As ??????) As Boolean Return (TypeOf ctrl Is thisType) I need a function that I can call, for example, to determine if a control is type RichTextbox.dim z as Boolean= IsType(txtBox1, RichTextBox) I ned to determine if a control is a given type (i.e., not always RichTextBox). I don't know what Type to make thisType. Can this be done?Actually I simpified the problem but if the above is answered I can write the function
View 4 RepliesI have inherited a vb6 app that I am trying to upgrade to VB2008.
If I can find out that a control has a ToolTipText property as below, how can I get the value?
For
Each ctl In frm.Controls
If Not (ctl.GetType().GetProperty("ToolTipText") Is Nothing) Then
[Code].....
I am retrieving some records from a database dynamically, not knowing exactly which table I need to query, or even which fields to retrieve. I display this data in a control that looks a bit like a listbox, except each item is two lines: a label and a value. Now, the user needs to be able to browse through this list until he finds the item he needs, and then he should be able to edit the item.
This application will (eventually, this is just a 'proof of concept') run on a mobile device or PDA or something like that, so space is limited. To allow the user to edit a value, I simply show a panel containing some edit control (textbox, checkboxes, combobox, etc), let the user edit whatever he's editing, save the change and display the list of items again.[code]...
I need to determine the type of a WinForms control in a collection.
[Code]...
I've make a UserControl and want only buttons can be added to its ControlCollection, if others controls are added, it will throw an exception.
View 4 RepliesI'm trying to create a new server control type in ASP.NET. This control would put a RequiredFieldValidator into a certain place. My class inherits from the WebControl class and it has a ControlID property which is the ID of a given control. The RequiredFieldValidator will be generated near the control with the given ControlID. However, the value of ControlID is nothing. In what events can I successfully use this property?
Public Class MyControl
Inherits WebControl
'...
Protected Property ControlID As String
Protected Property IsLinkedBrother As Boolean = False
[Code] .....
But ControlID is Nothing for some reason and the event throws an exception. ControlID is never changed after initialization and it is initialized this way:
<MyControl runat="server" ID="IDValue" ControlID="ControlIDValue" EnableCliendScript="true" CssClass="Whatever" Display="Dynamic" />
I'm writing a program in which I want to list the values of some of the properties on every control on every form in the application. I can do this for simple controls like Buttons and Labels, but am having a problem when it comes to a complex control like a ListBox. I know how to extract the data when I laboriously code each ListBox individually. The problem is how to do it when it's a generic object buried inside two loops
View 7 RepliesIs there a control in .NET that allows you to create boxes with input and output pins which can then be connected? A good example is Graphedit
View 1 RepliesAll my controls for getting data from user are in TableLayoutPanels and GroupBoxes inside TableLayoutPanel, I want to set default selected index of entire CoboBoxes to 0 in all TableLayoutPanelsand and GroupBoxes inside TableLayoutPanel. [code]...
View 23 RepliesI am looking for a VB control that operates as a more or less transparent or semi-transparent ruler or bar that can be scrolled up and down the form over an invoice or letter, so that the user can see what is under the ruler/bar and thus stop scrolling when he reaches a certain point.
To give a bit more detail of what I am looking for - such a bar is used when someone is setting the focus on a line of a long list of items so that they know where they are all the time. Most people would use a ruler on a paper list to keep track of how far they have progressed down the list. It would be nice though to have the "ruler" or bar as semi-transparent so that the user can see under where he is at on the list or form.
How do I make my app identify the forum type that the webbrowser control is currently viewing? I want to make the app determine weather it's a vBulletin board or a phpBB board, but I don't know how to do it..
View 10 RepliesI need to develop an inbox/outbox/sent items type interface and I believe that copying the outlook view would make it much easier for my users.I just can't seem to find any control for VB.NET that copies the feel of Outlook.
View 1 RepliesI have a small piece of code that iterates through the controls collection on a panel (below) Everything works fine until I want to focus on a control that doesn't support the selectall method i.e. a datetimepicker. Is there any way of determining the type of control and not call the selectall method when the type is datetimepicker. All my other controls support it so that's the only one I need to exclude.
[code]...
I've created the following basic function to determine whether specific control type is currently loaded:
Private Function IsPreviewerTypeLoaded(Of T)() As Boolean
For Each previewer In LoadedPreviewers
If previewer.GetType().Equals(T) Then
[Code]....
I need to compare each control against the generic type supplied. Equals(T) fails to do the job, producing a compiler error. How to make it correctly?
UPDATE: is the following correct?
previewer.GetType().Equals(GetType(T))
I need a 2-listbox mover/selection type control such as the example here: [URL] For over a week now I've searched countless forums and done myriads of googles. All I've been able to find is C++ or ASP based stuff. I really would like this to be VB.net, but at this point, I'd even settle for C#.
I've taken a shot at developing it myself, but am too new to the .Net world to really get anywhere with it other than being completely overwhelmed and frustrated. I've even looked at some 3rd party custom control webistes, and am even willing to spend a few bucks for this thing, if I could find one that suits my needs.
[Code]...
I want to make a simple file re-naming utility and do not know how to get the images for the known file types.
View 1 Replies