C# Windows Form - access code [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need to know where I can access the basic code, for example a "NumericUpDown" Element.
What I want to do:
Add Code to my NumericUpDown Element, for example:
Set the "Maximum"-Value to a variable embedded inside my Formclass code.
The Reason why I cant to it right now:
I just can access the NumericUpDown Element just in the Design View right now. There I can Input a value, but can't set it to the amount stored in a variable.
I just know, that If I double click the field, I get a "ValueChanged" Method into my code. But what I need to know: How can I access the "basic" Code of the NumericUpDown Element, where I could set the "Maximum"-Property?
I'm relatively new to programming. And I'm quite overwhelmed with a lot of things... So I COULD google for the problem but it would just take me way to much time.
Since I guess it's an easy answer for you guys, I post it here.
Thanks a lot!

You can access the Control's objects attributes by it's name.
For example:
NumericUpDown1 <- It's the name of your Control
In your C# code you can access all of it's attribtes and methods by puttin a period after it's name:
NumericUpDown1.Maximun = 100;
NumericUpDown1.Width = 250;
NumericUpDown1.Height = 10;
etc. You can serach it by "Control Properties" in google. Luck and effort! :P Remember to try and search a bit before asking. Don't wait for others to make your job. Luck! ^.^

You can access source code of components, but it won't help you. every component has interface and you can use it's interface to interact with it. Also you can override some methods of component to change their behavior.

Related

Is there any command that allows me to check if any class has objects created from it? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
So, I'm writing some code for practice and I've come to a point where I want to make a function where I can check a class for objects made from it and then, be able to use the methods and/or data fields I've written on the objects
Like, let me use a kind of blunt example
Dog.CheckForObjectsOfSameClass();
I've tried using a static number to refer to to then refer to the parent of such data, but I can't find a command for that either.
I would post the code I've tried to use before, but it would just make this the more confusing.
Thanks in advance for any answer that can help me solve this doubt
It sounds like you're asking for something like built-in reference counting. Other than the garbage collector there isn't anything like this in the language, and trying to hook into the garbage collector just to write normal application code would in my opinion be an utterly weird, crazy and plain dreadful thing to do.
As one of the comments suggests, this sounds like an XY problem, where the real solution is to understand why holding a reference to the object you want to access is difficult, and change your coding approach to do this in a more straightforward way. Depending on exactly what you are trying to do, adding a newly created object to a dictionary:
var dogs = new Dictionary<string, Dog>();
var rover = new Dog();
dogs.Add("rover", rover);
using a meaningful key to distinguish which object is which, might be a way of solving the problem.

C# ParentForm.ActiveControl.Name [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
if (Operators.CompareString(this.ParentForm.ActiveControl.Name, this.Name, false) == 0)
{
base.Focus();
}
From What I have experience in VB6,the above code doesn't work because they are never equal if the users didn't change to the same name.
From Example, the UserControl Name is ucCalendar, When I drag to my From, the name will automatically change to ucCalendar1,even though I can change to ucCalendar but usually we won't do that.
I think the coder want to compare whether the UserControl is the only control or ActiveControl on the Form so that he can force to focus it.
I don't know this C# works or not. Please tell me.
There is nothing in the WinForms code saying that two controls can not have the same name. The reason you think that is that you're looking at it from the designer perspective, when you use the designer it won't let you have two controls with the same name just because it uses there as field names for them in the code, and as you probably know there can not be two fields / properties / variables with the same name in the same scope. As a matter of fact there is no need for the Control's Name property to be anything.

Dynamic Programming and alike in c# [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I need to learn a certain programming subject and I don't know where to start, would like your help.
This is what I need do do, I have a user form (UI) and the user enter "Rules" in the form of:
if operator(obj1) then assign(obj1,string)...
I take this rules, and translate them into actual code, and I want to put that code somewhere in a function/my code.
for example:
main {
UI...
/* when we reach here, means the user done writing rules */
/*Function that translate the user rules to actual code */
translate();
for {
/* This is where I want to put the code after translation */
}
}
How do I put the code inside the loop (or anywhere else for that matters) after the program started running?
I ofcourse don't look for an actual answer, more to give you an idea what I need so you can refer me to a certain subject to study about.
I presume, you are in process of creating a custom rule engine, which has the capability of validating your rules on fly. Within my ability, you need to start reading c# scripting, code generation, dynamic loading or reflection etc are some to start with.
To give a kick start, following are some of the step which I can think off;
Grab the rule definition (xml or csv)
Write a small helper which will read rule entries from the definition and convert it into
c# source code. This is similar to c# scripting.
On successful completion of (2), create a dll out of the source code
Now reflect/dynamically load the dll from (3) to where ever you wanted to validate the rule.

Writing Multiple Fields to one textbox [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Just need a little help with a program i have been working on. basically i work in a call centre and i am going to use this to record my notes during calls, i have everything worked out besides on feature. So i when filling out the fields i need it to show up in a specific textbox, and i need to structure this data to specific lines. I also want to try do this without having to store the data to txt file or a database, i want to try do it all within strings if possible. any help would be greatly appreciated guys.
thanks in advance
So in short.. you just created a button and some fields and have no idea how to proceed.. try selecting one programming language as #TheKingDave suggested. For example, if you go for C#..
try to read up on the below links to get yourself started:
system.windows.controls.textbox
system.windows.controls.combobox
but just, if I understand your question correctly, because let's face it, it's far from clear, you want to grab information you added into several textboxes and comboboxes etc and format them into one multiline textbox? If so...
Create a on_click event for your button in which you want to add stuff like..
string Example1 = this.mytextbox1.text;
string Example2 = this.mytextbox2.text;
string Example3 = this.mycombobox.SelectedItem;
...
afterwards you want to add all these strings together, for example
string MyResult = "Example1: " + Example1 + "\r\n" + "Example2" + ... ;
and then show this in your resulting textbox
this.myresulttextbox.text = MyResult;
Hope this answers your question somewhat but I strongly advise reading up on this before going any further..
What is actually your programming language?
Not sure about your question but if your goal is to concatenate everything into a single string, just read the text value from every *boxes you have and add them into the text value of your destination using a special joker character that is unused in your edited fields like 'ยค' for example to separate every string. It's easy then to process it later. The brutal way is to hard code every copy. A slightly more refined one would be to have a list of interesting components and for the copy to loop on them and according their type, chose the right access method to get the information.

Creating an application for Math Practice with ASP.NET [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am trying a develop a Math Practice web application using ASP.NET (not MVC), which allows Users to perform Multiple choice or simply type an answer, click a button and see answer.
The first idea that comes to mind is simply get permission to use a book, grab all the questions and answers using a DB and display the right answer. But how would I display the answer or the show me how the answer was derived.
My confusion is; how does this work?:
Do I have to write all the formulas and answer myself?
Are there programs for this?
I do not even know where to start.
What I would like to do is have the user select an answer, if the answer is wrong, they can click the show me button.
I am looking to either write this in C#, Visual Basic using JQuery on the front end.
Just need some direction.
Thanks my friends.
When I was in college I had to do something very similar.
What I did is stored expressions 4 + 5; 1 * 6 in database and then pushed those expressions to evaluate on run-time because it is pretty easy in C#.
It takes expression from database 2 + 2
It evaluates the expression on run-time producing result 4
You get your result and show it to user or do whatever with it
More info on how exactly to do that: http://www.c-sharpcorner.com/UploadFile/mgold/CodeDomCalculator08082005003253AM/CodeDomCalculator.aspx
I don't think you need to evaluate a stored expression. Since you just want the user to enter multiple choice or the answer itself, just set up your database as follows:
QuestionAnswers:
ID (uniqueidentifier) (primary)
QuestionText (varchar)
QuestionAnswer (varchar)
ShowMeHowEquation (varchar)
Then, display the ShowMeHowEquation via jQuery like so:
Show Me How
<div class="showMeHowEquation">Database driven contents here...</div>
<script>
$(document).ready(function() {
$('.showMeHow')click(function() {
$(this).next('.showMeHowEquation').slideDown();
});
});
</script>

Categories