Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
QuestionMD file Pin
Member 1384619127-May-18 5:30
Member 1384619127-May-18 5:30 
AnswerRe: MD file Pin
Dave Kreskowiak27-May-18 6:17
mveDave Kreskowiak27-May-18 6:17 
AnswerRe: MD file Pin
OriginalGriff27-May-18 6:27
mveOriginalGriff27-May-18 6:27 
AnswerRe: MD file Pin
Richard MacCutchan27-May-18 6:44
mveRichard MacCutchan27-May-18 6:44 
PraiseRe: MD file Pin
Eddy Vluggen27-May-18 6:56
professionalEddy Vluggen27-May-18 6:56 
AnswerRe: MD file Pin
Member 1384619127-May-18 7:03
Member 1384619127-May-18 7:03 
GeneralRe: MD file Pin
Eddy Vluggen27-May-18 10:17
professionalEddy Vluggen27-May-18 10:17 
QuestionUsing ComboBox values to create variables and making calculations Pin
Member 1384637627-May-18 4:59
Member 1384637627-May-18 4:59 
Hi, I am a beginner in C# and programming in general. I have a problem getting started with C#, and I need some tips for one project I'm doing for myself.

In general I need a list of items in a combo box, and based on the selection in the combo box I need some variables to take different values, then make calculations based on these values and produce a numerical result into a TextBlock.

For now I understand that I should do it like this (but I am missing a lot):

1. I made a class like this (in MainWindow.xaml.cs):
class Concrete
{
    public double CompressionStrength { get; set; }
    public double YoungModulus { get; set; }
}

create some instances of this class like this:
Concrete C37 = new Concrete();
 C37.ConpressionStrength = "30";
 C37.YoungModulus = "21"

 Concrete C30 = new Concrete();
 C37.ConpressionStrength = "25";
 C37.YoungModulus = "21"


2. I made a combo box in MainWindow.xaml

<ComboBox x:Name="ConcreteList"> 
</ComboBox>


3. Now I need to somehow populate the combo box with different instances of my class, like:
<ComboBox.item1 = C37/>
ComboBox.item2 = C30/>


4. Then I need to create some variables based on the selection in the combo box and make some calculations, for example:

if TextBoxSelection=C37;
  double a = 10;
  double b = 20;
  double CompressionStrength = C37.CompressionStrength;
  double c = a*b*CompressionStrength;
else .... 
end if 

5. And then I just need to print value "c" to a TextBlock in the WPF window.

Now I need to ask for some general guidance about this because I am a little stuck...
1. How do I populate combo box in MainWindow.xaml with names of my class instances that are in the MainWindow.xaml.cs?
2. How do I create a numerical variable from the class property and perform calculatons on it?
3. Is it even doable this way / what would be your suggestions for making this work?

I would be grateful for any comments.
AnswerRe: Using ComboBox values to create variables and making calculations Pin
Gerry Schmitz27-May-18 8:11
mveGerry Schmitz27-May-18 8:11 
QuestionLoad an .net assembly dll dynamically and consume its methods Pin
paulogomes25-May-18 6:33
paulogomes25-May-18 6:33 
AnswerRe: Load an .net assembly dll dynamically and consume its methods Pin
Gerry Schmitz25-May-18 7:52
mveGerry Schmitz25-May-18 7:52 
GeneralRe: Load an .net assembly dll dynamically and consume its methods Pin
Peter_in_278025-May-18 13:08
professionalPeter_in_278025-May-18 13:08 
GeneralRe: Load an .net assembly dll dynamically and consume its methods Pin
Gerry Schmitz25-May-18 13:56
mveGerry Schmitz25-May-18 13:56 
QuestionNewton Raphson method coding with C sharp Pin
Member 1384337224-May-18 9:53
Member 1384337224-May-18 9:53 
AnswerRe: Newton Raphson method coding with C sharp Pin
#realJSOP24-May-18 11:43
mve#realJSOP24-May-18 11:43 
GeneralRe: Newton Raphson method coding with C sharp Pin
OriginalGriff24-May-18 20:00
mveOriginalGriff24-May-18 20:00 
GeneralRe: Newton Raphson method coding with C sharp Pin
Gerry Schmitz25-May-18 7:20
mveGerry Schmitz25-May-18 7:20 
QuestionHaar Cascade Car Pin
Member 1373868124-May-18 8:11
Member 1373868124-May-18 8:11 
QuestionRe: Haar Cascade Car Pin
Gerry Schmitz24-May-18 10:41
mveGerry Schmitz24-May-18 10:41 
AnswerRe: Haar Cascade Car Pin
OriginalGriff24-May-18 20:02
mveOriginalGriff24-May-18 20:02 
GeneralRe: Haar Cascade Car Pin
Gerry Schmitz25-May-18 7:16
mveGerry Schmitz25-May-18 7:16 
QuestioniTextsharp - Adding radio button image to .pdf Pin
User 1367511422-May-18 22:47
User 1367511422-May-18 22:47 
AnswerRe: iTextsharp - Adding radio button image to .pdf Pin
Richard Deeming23-May-18 1:11
mveRichard Deeming23-May-18 1:11 
GeneralRe: iTextsharp - Adding radio button image to .pdf Pin
User 1367511425-May-18 3:07
User 1367511425-May-18 3:07 
QuestionHow the find and assignment field with DataView type ? Pin
Member 245846722-May-18 17:18
Member 245846722-May-18 17:18 

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.