I'm not sure if the question properly asks what I want, because I'm a bit new, but what I am trying to do is write a sub or function that I can run when a label is clicked, and I want to to be reusable on multiple labels. There will be 12 in total, and I don't wish to write the same thing over and over, with slightly different characters. A programmer never wants to write the same thing twice, right? Also, something else is making it a necessity to do it dynamically.
So, how I was trying to accomplish that was by using a string, and adding the name of the label to the string on click.
click1 = "Label1"As it turns out, you can't just say click1.Text and return the text of Label1. The reason it's important to do it implicitly is because I need to somehow remember the one I clicked before, to compare the first click and second click, and if they match, do A, and if they don't match, do B.
I am coding a public sub routine that clears all textbox fields in a form. I want to call/reuse this sub routine everytime i want to clear all textfields in any form in my program.
I can create a collections of all textbox objects in a form and loop on each of them to clear their textfields.
I have a class library that contains a number of classes. I would like to dynamically create an instance of one of these classes, set its properties, and call a method.
Example:
Public Interface IExample Sub DoSomething() End Interface Public Class ExampleClass
Error Message Object reference not set to an instance of an object.
Dim intBoxNumber As Integer Dim rbl As RadioButtonList For Each drv IN dv intBoxNumber = drv("BoxNumber") rbl = DirectCast(FindControl("rblPageSandBox" & intBoxNumber), RadioButtonList) rbl.Items.FindByValue("intPageSandBox" & intBoxNumber).Selected = True Next
I have two DataTables, PersonInformationDataTable on which i only know about a "CityName" field, and another CityInformationDataTable, which has a few constant fields and i do a query like
ResultOfQuery = From person As DataRow in PersonInformationDataTable From CityInfo As DataRow in CityInformationDataTable Where (person("CityName) = CityInfo("CityName")) Select ?? all person info ?? , Country = CityInfo("Country"), Tongue = CityInfo("SpokenTongue")
I would like again all the person fields with their values in the enumerable result.
the result would be like : name=. I don't know how many fields or the fields name of PersonInformationDataTable in advance. With a SQL Query, i could write a string with a loop on CityInformationDataTable columns and have a custom select string like : "Select Name,
My _PrefillWizard method actually works for all the controls on my page except for those which are dynamically populated. The CheckBoxLists are such because they are automatically generated based on selectable values in a table in my DB. I already have this control in my markup like so... how do I force this to load and be ready before running my other code?[code]...
how I can select a row and column dynamically in EF4? (VB).A bit like a map, I want to navigate through the data using x and y axis to pull out one fields value,SQL would look like this
SELECT " & MyColumbVariable & " FROM MyTable WHERE MyRow = " & MyVariable & "
I'm developing an application to allow engineers to conduct simple single table/view queries against our databases by selecting Database, Table, Fields.
I get how to use the Dynamic LINQ Library Sample to provide for dynamically selecting the Select, Where and Order by Clauses at runtime but I'm at an impass on how to allot for table choice.
Is there a way to provide for dynamically selecting the "from" table at run time
EDIT
So Both of the answers seem to be saying the same general Idea. I'm going to try to convert the C# into VB and get it to work.
The first answer converts to
NotInheritable Class DataContextExtensions Private Sub New() End Sub
dim object1 as new clsDatadim object2 as object object2 = getobject("object1") "getobject" function is my "needed function"
the purpose is to set object2 to have same memory address with object1 so if i change the properties of object2 then the properties of object1 also changes..
Dim oMyObject As New MyObject oMyObject.DoSomething("Parameter1","Parameter2")
The "DoSomething" and the two parameters are dynamically provided from another script. They are stored in a string object in this script: sAction & sParameters. My question is how can I dynamically pass the "sAction" to the object oMyObject.For example oMyObject.sAction (where sAction should be the value stored in the sAction string). The example will probably not work. Is there a way to do this? The idea behind is to avoid having to write each function hardcoded, like:
If sAction = "DoSomething" then oMyObject.DoSomething(sParameters) ElseIf sAction = "AnotherThing" then
I am trying to create an object dynamically with CreateObject function. The code is below but it gives error:"ActiveX object can't be created" while calling the CreateObject function.
Public Class Form1 Public Delegate Sub DButtonClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Private Sub DButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) MsgBox("You hit me")
I'm trying to reference a public property from a string. How can this be done in vb.net?I have the text value of "FirstName" stored in strucParam(i).TxtPropertyName.[code]...
I'm making a little program in where i'm trying to invoke a method from a class dynamically with so called Reflection.
The class I'm trying to call is called ContactList and i try to invoke the property in this class called count. The assembly itself is called Contact.Exe
Now I have the following code where I make an instance of the ContactList class in the Contact.exe assembly:
Below is some code that I'm using to create objects with Visual Basic:
For indexCounter As Integer = 1 To TotalParticipants Step 1 participantClock = New Label participantClock.Size = New Size(100, 20) participantClock.Name = "participantClock" & indexCounter
[code]....
I'm creating a label, a button, Timer, and Stopwatch. (Though I have sinking feeling I don't need BOTH a timer and stopwatch since I'm counting time.)What I would like to do, is create the label and set that label's text to be the value from the stopwatch. The button that will be created will stop THAT stopwatch.
The problem that I'm having is that I cannot call the stopwatch by name since it wasn't created yet and VB throws a hissy fit at me for it. (After all it wasn't really declared.)So the question becomes, how do you call the most recently dynamically created control and assign events using that control. If it's not possible to do, I do not mind dumping the form and starting over creating 30 stopwatches instead (but I'd like to avoid that, if possible).
I can't quite figure out why this Linq Statement isn't working as i would expect:
[Code]....
I would assume that this would create a new collection of anonymous types, that would be distinct. Instead it creates a collection the size of the "ThisParentCollection" with duplicate "MyAnonymousType" in it (duplicate id's).
Is it possible using Linq to select the FirstName and LastName out of all the Bloops in the collection of Bloops and return a collection of Razzies? Or am i limited to a For-Loop to do my work?
To clear up any confusion, either VB or C# will do. Also this will probably lead to me asking the question of (What about using a "Where" clause).
What I have is 4 datagridviews named dgv1, dgv2 etc.I also have a variable curr_player whose value is between 1 and 4. I would like to be able to enable one of the dgvs based on the value of the curr_player variable. I'm reluctant to to write select case for each time I want to do this so the question is can I enable one of these objects based on that variable?
What I have is 4 datagridviews named dgv1, dgv2 etc I also have a variable curr_player whose value is between 1 and 4. I would like to be able to enable one of the dgvs based on the value of the curr_player variable. I'm reluctant to to write select case for each time I want to do this so the question is can I enable one of these objects based on that variable? something like Datagridview(curr_player).enable=true
In the form load I generate a radiobutton for each label, with the text property being the name of the label.So two radiobuttons are made The first one will have text: Label1 I have
Quote:
dim objStore as object
Example:I select the first radiobutton (text: Label1)Then Label1 should be stored in objStore as object.So then I can do
i have a Openfiledialog1 and a Picturebox1 how can i select a image in the openfiledialog and when i press Ok or Open the image shows in the picturebox like a picture
I have done a lot of searching to what appears to be a simple LINQ problem but I can't figure out how to do grab an object out of a collection that has a specified minimum (or max value) without resorting to a sort like this[code]...
I was able to do this via a SELECT CASE statement, however I'm always trying to improve my code writing and was wondering if there was a better approach. Here's the scenario:Each document has x custom fields on it.There's y number of documentsHowever there's only 21 distinct custom fields, but they can obviously have n different combinations of them depending on the form.So here's what I did, I created an object called CustomFields like so:
Private Class CustomFields Public agentaddress As String Public agentattorney As String
I have a combo box that is populated with a list of objects (corresponding to all employee rows from a database that meet the criteria IsTech). These are not entity objects though, I have created my own class that stores the member values of each row from the DB. I have set the DisplayMemberPath to EmployeeId so the Combo box display the EmployeeId ( an integer ) member of my object. Ie. right now there are only 2 IsTech employees in my DB so the combobox displays the numbers 3 and 8 ( their EmployeeIDs).
[code]How would I switch on an object's type but using VB.NET's Select Case?I'm aware that some might suggest using polymorphism but I'm using a hierarchy of small message classes so that really wouldn't work in my csae.
I'm looking to add reference object libraries relating to excel and none are available to select from my directory. I have Microsoft Office Excel 2010 Express installed. Where can I retrieve this object library (and others?). Looking to import and export data to/from excel.
Code: Public Class Form1 Dim NPB As Button Dim x As Integer
[code]....
As you can see, when I open a program from my menu, a new button will be created with text similar to this, "C:Program ". The button it self will not do anything. How can I create the method at the same time the button it is for is created? Also how can I change the text do that it gives me, for example, CCleaner.exe instead of the whole target path?