Click here to Skip to main content
15,879,095 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Richard MacCutchan1-Dec-23 2:06
mveRichard MacCutchan1-Dec-23 2:06 
AnswerRe: C# code to chart sometimes charting blank charts Pin
Dave Kreskowiak1-Dec-23 5:02
mveDave Kreskowiak1-Dec-23 5:02 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Andre Oosthuizen1-Dec-23 22:30
mveAndre Oosthuizen1-Dec-23 22:30 
AnswerRe: C# code to chart sometimes charting blank charts Pin
jschell1-Dec-23 6:35
jschell1-Dec-23 6:35 
AnswerRe: C# code to chart sometimes charting blank charts Pin
Gerry Schmitz2-Dec-23 8:02
mveGerry Schmitz2-Dec-23 8:02 
GeneralRe: C# code to chart sometimes charting blank charts Pin
Iskander123452-Dec-23 16:02
Iskander123452-Dec-23 16:02 
Questionc# code Pin
j k Nov202329-Nov-23 17:13
j k Nov202329-Nov-23 17:13 
AnswerRe: c# code Pin
lmoelleb29-Nov-23 19:31
lmoelleb29-Nov-23 19:31 
GeneralRe: c# code Pin
j k Nov202329-Nov-23 20:04
j k Nov202329-Nov-23 20:04 
AnswerRe: c# code Pin
jschell30-Nov-23 6:05
jschell30-Nov-23 6:05 
AnswerRe: c# code Pin
Andre Oosthuizen1-Dec-23 22:35
mveAndre Oosthuizen1-Dec-23 22:35 
GeneralRe: c# code Pin
j k Nov20232-Dec-23 20:34
j k Nov20232-Dec-23 20:34 
GeneralRe: c# code Pin
Andre Oosthuizen3-Dec-23 2:35
mveAndre Oosthuizen3-Dec-23 2:35 
QuestionConverting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Codice Fictor26-Nov-23 12:19
Codice Fictor26-Nov-23 12:19 
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…………………….
AnswerRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Dave Kreskowiak26-Nov-23 14:07
mveDave Kreskowiak26-Nov-23 14:07 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Codice Fictor26-Nov-23 15:52
Codice Fictor26-Nov-23 15:52 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Richard MacCutchan26-Nov-23 21:28
mveRichard MacCutchan26-Nov-23 21:28 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Gerry Schmitz26-Nov-23 21:45
mveGerry Schmitz26-Nov-23 21:45 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Codice Fictor27-Nov-23 4:08
Codice Fictor27-Nov-23 4:08 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Gerry Schmitz27-Nov-23 5:54
mveGerry Schmitz27-Nov-23 5:54 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Codice Fictor27-Nov-23 6:47
Codice Fictor27-Nov-23 6:47 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Gerry Schmitz27-Nov-23 7:07
mveGerry Schmitz27-Nov-23 7:07 
QuestionRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Eddy Vluggen27-Nov-23 7:46
professionalEddy Vluggen27-Nov-23 7:46 
AnswerRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Gerry Schmitz27-Nov-23 15:48
mveGerry Schmitz27-Nov-23 15:48 
GeneralRe: Converting string into non-string Form.Object types for passing to methods or updating non-string object.Property with strings Pin
Eddy Vluggen28-Nov-23 0:42
professionalEddy Vluggen28-Nov-23 0:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.