Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings
-
Sounds a lot like a decorator pattern. Do you despise it? I mean, I do like adding functionality by using a decorator, and the .NET framework apparently too, as there are a lot of places where we use them.
Bastard Programmer from Hell :suss: "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
I said a wrapper can hide or "facilitate"; which is a good thing. I wrapped a C++ "animation" engine in a FoxPro dll so I could generate 3rd graphics using FoxPro. I did it to earn a license that normally cost $8,000. (A "long" time ago). I could create and race a buggy over 3D terrain ... The ultimate plan was to use the graphics engine in my "rail car repair system", but that's another track.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
It’s getting clear now…. Because of my background and my only experience with C# is working with objects, refs and pointers created and generated at run time, I was lost on setting up a reference (linking them) in my code with the instantiation of a pre-existing object dragged onto the Form. Every help link is about creating an object with your definitions and manipulating what you created not syntax/methodology on decoding what you didn’t create. Thank you……….. And I understand Class and SubClass structure but not how to maneuver around in it in C#. Now that I can pass my Form Control around in my code I’m not sure the buzz words to comprehend this problem (abbreviated): private void ManuplateButtons(Control InputButton) { InputButton.Text = // Good Button12.FlatStyle = // Good (pre-instantiated on Form) InputButton.FlatStyle = // CS1061 'type' does not contain a definition ………… Button FlatStyle is available but Control FlatStyle is not in the list of parameters. So now I need to learn how to dig into the object reference(Control InputButton) to find how FlatStyle is referenced inside of the object reference (Control InputButton). Is it Control.InputButton.A.B.C nope, so I need to learn how to navigate into the object reference (Control InputButton) and query where FlatStyle is stored or discover what else I can do with an object I didn’t create. I imagine this is not an across the board answer because of the many things you could put/reference in an object. Timeout; I was composing this when I just read jschell’s post. I believe I have caught up to your post. In reference to above and #1: I usually depend on the Visual Studio dropdown list and look up the details of the options available until I find the parameter/function that I need or the research of the p/f leads me to an answer. The available button12.X where x = Flatstyle, Flatstyle is in the list but in the case of reference(Control InputButton). Flatstyle is not in the list so I must find it……….. methodology unknown to me ‘yet’. “…..convert from string to enum” but I need to find the enum def for reference(Control InputButton).Flatstyle before I can convert my string to the relevant enum. I understand the cross correlation between 1 & 2 of jschell’s post. What are the key search phrases of OOP for the methodology and implementation of how discover what is enumerated in an object that is not shown in the dropdown list, because if “string must match the name of the e
Button, inherits from ButtonBase, which inherits from Control. FlatStyle is defined in ButtonBase. At a minimum, you need to "cast" Control to ButtonBase to access that property. As a side note, ButtonBase is an "abstract" class: you can't actually create ButtonBase except via a class that inherits it (like Button, CheckBox, and RadioButton; or your own "custom" button).
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
I said a wrapper can hide or "facilitate"; which is a good thing. I wrapped a C++ "animation" engine in a FoxPro dll so I could generate 3rd graphics using FoxPro. I did it to earn a license that normally cost $8,000. (A "long" time ago). I could create and race a buggy over 3D terrain ... The ultimate plan was to use the graphics engine in my "rail car repair system", but that's another track.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
A "decorator" is usually there to add functionality?
Gerry Schmitz wrote:
I could create and race a buggy over 3D terrain
Now there is some code I'd like to read and learn from :) I'm really bad at making games, I do forms and databases.
Bastard Programmer from Hell :suss: "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
A "decorator" is usually there to add functionality?
Gerry Schmitz wrote:
I could create and race a buggy over 3D terrain
Now there is some code I'd like to read and learn from :) I'm really bad at making games, I do forms and databases.
Bastard Programmer from Hell :suss: "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
I'm sure, with a bit of lateral thinking, you could make a game out of form filling.
-
I'm sure, with a bit of lateral thinking, you could make a game out of form filling.
Way off topic; I'll try. If I succeed, it will become a new article. ..I just never looked at it that way; it is a game, not a form. Input is input, regardless where it comes from? Thank you for making my day :)
Bastard Programmer from Hell :suss: "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
-
A "decorator" is usually there to add functionality?
Gerry Schmitz wrote:
I could create and race a buggy over 3D terrain
Now there is some code I'd like to read and learn from :) I'm really bad at making games, I do forms and databases.
Bastard Programmer from Hell :suss: "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
What is a "game"? I was a Windows Form evangelist because WPF didn't have a data grid at the time. Then WPF ... I now use UWP because it gets me in the Store, for one thing. (But now any exe can be added to the Store.) My game consists mostly of moving rectangles around and measuring angles and distances. "Gettysburg!" It's under "Books and References" so I don't pay the "game premium".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
Button, inherits from ButtonBase, which inherits from Control. FlatStyle is defined in ButtonBase. At a minimum, you need to "cast" Control to ButtonBase to access that property. As a side note, ButtonBase is an "abstract" class: you can't actually create ButtonBase except via a class that inherits it (like Button, CheckBox, and RadioButton; or your own "custom" button).
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
Thank You Jerry, ButtonBase BUTTONx = this.Controls.["button1"]; I tried that before and ButtonBase doesn't associate with the string name. I get error CS1001 at the '['. This doesn't work either ButtonBase.Button BUTTONx = this.Controls.["button1"];
-
Thank You Jerry, ButtonBase BUTTONx = this.Controls.["button1"]; I tried that before and ButtonBase doesn't associate with the string name. I get error CS1001 at the '['. This doesn't work either ButtonBase.Button BUTTONx = this.Controls.["button1"];
-
Thank You Jerry, ButtonBase BUTTONx = this.Controls.["button1"]; I tried that before and ButtonBase doesn't associate with the string name. I get error CS1001 at the '['. This doesn't work either ButtonBase.Button BUTTONx = this.Controls.["button1"];
I posted about "is" and "as" already in this thread; which would have answered your question. The other aspect related to "is" and "as" is "boxing"; but that is generally used for "value types".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
-
Hello & Salutations to Everyone, using: Win Forms .NET 4.7.2 I have a set of Form buttons named button1, button2, button3,……… I have an array of strings BUTTON_LIST_str[] =” button1”, “button2”, “button3”,… I have a function: private void APPLY_BUTTON_CFG(Button b) { …………… } What I need to do is loop through BUTTON_LIST_str[] and pass each button object to APPLY_BUTTON_CFG(Button b). Basically for every string I need to use for pointing to a different type form object or its property of object, I get the error "String cannot be converted to the object required type/format (System.Form......) I have searched every convoluted order of words for hours and cannot find a solution that matched my scenario of converting strings to all form object types (or specific ones either). With so many unique object specific variables how does one research the solution to convert a string to each type for each case? Is there a ConvertToType universal function that solves this issue. I also ran into same problem with: FlatStyle P_STYLE = “Flat”; Button1.FlatStyle = P_STYLE or FlatStyle.P_STYLE ; // error cannot convert string to…………..FlatStyle object type I understand that a string name cannot point to a form object OOP when passing to a function. I’m not sure I can ask my question competently…………. With so many unique object specific variables how does one research the string conversion solution for each case? Simply put, how would I research and find the solution for these types of problems: Button1.FlatStyle = How to convert string to FlatStyle object reference, or Font, TextAlign when an error occurs? I did find this translator for colors but not FlatStyle though or for any other applicable parameters. P_COLOR = System.Drawing.ColorTranslator.FromHtml("White"); //"White" will be replaced with a string array element CFG_PARAM_PARSED[2]); Button1.ForeColor = P_COLOR; This is the real kicker: Button name as string (String_Array[x]) needs conversion (typecast?) to object name reference var ButtonObject = String_Array[x]; or Button ButtonObject = String_Array[x]; APPLY_BUTTON_CFG(ButtonObject); private void APPLY_BUTTON_CFG(Button b) { …………… } Thank You So Much for your time and assistance…………………….