C# :: Pass Values Between Forms Using Get And Set Properties?

Jan 15, 2015

Well I know how to pass values between forms using get and set properties. But the problem with it is everytime I want to pass values from form2 to form1 it doesn't appear. To make it appear I have to type form1.Show(); which open form1 a second time and then show the value. Is there any way I could make it appear without using form1.Show();?

View 9 Replies


ADVERTISEMENT

C# :: Passing Properties Between Forms

Nov 2, 2014

I've been attempting to design a multiform WFA in Visual Studio 2010, but I'm so rusty with the language it's hard to remember how to do a lot of things, especially when it comes to visual programming, which my class only partially covered. I've never made a multiform application before, and my problem essentially boils down to how to pass data between forms.

My application is a simple item list and order form, sort of mimicking what you might see on a site like Amazon or eBay. My first form contains a drop down list and 'checkout' button. The dropdown list has been populated with an object collection, each object holding the product's name and price.

public partial class Form1 : Form
{
//Item class for dropdown menu
public class Item {
public string Name;
public decimal Price;
public string itemName

[Code] ....

When the 'checkout' button on form 1 is clicked, I want the Price and Name properties of the selected droplist item to appear in a pair of text boxes on form 2 for the purpose of lowering the user's cognitive load (if they can see what they've selected, it's one less thing to remember).

I've seen plenty of tutorials on how to send a textbox Text property between forms, but none for how to do this. As I said, I'm rusty with the language, and I'm pretty sure there's a better way to set up my combobox items, but I can't remember how to set it up.

View 12 Replies View Related

C# :: Passing Values From Different Forms

Mar 21, 2014

So form two needs to pass information that was typed in its text box to form 3. So then form 3 can use this information. I think I am creating a new instance of form 2 because I get the exception can not divide by 0 so it is empty even if I typed in a integer in the text boxes. How to pass information from the textbox to a var that can be used in another form.

public partial class MapProperties : Form {
private int _numRows;
public int NumRows {
get { return _numRows; }

[Code] ....

View 2 Replies View Related

C# :: Passing Datagridview Values To Different Forms

Apr 2, 2015

I am currently writing a program which needs an edit form. This form is to edit a country in the datagridview which I have. I am however confused about how to pass the data from the data gridview in the main form to the relative places on the edit form. I have done most of the coding as shown below. I know I need a method in my AVL class to return all the information of the selected country back to the main form method which then passes it back to the edit form and displays it. I am unsure what to pass and what to write in this method.

Main form method

public void button2_Click(object sender, EventArgs e)
{
// creates new form referencing data grid view and AVL Tree
EditCountryForm editform = new EditCountryForm(ref this.countryTree, dataGridView1);
string CountryName = "";
//set name of country selected to string

[Code]...

View 2 Replies View Related

C++ :: Pass Values By Reference

Nov 7, 2014

I built a program that finds the average amount of days missed per employee. I am now attempting to modify my program to pass values by reference rather than passing by value. I created 3 functions: int numOfEmployees(); int numOfDays(int); double avgDays(int, int);

in the prototype I use the ampersand sign int numOfDays(int&);
in the actual function I use numOfDays(int& employees)

I am just not able to get the call to the function to work the program will crash when I modify it with the ampersand signs.This is the original code I am trying to modify:

#include <iostream>
using namespace std;
int numOfEmployees(); //Prototype for numOfEmployees
int numOfDays(int); //Prototype for numOfDays
double avgDays(int, int); //Prototype for avgDays

[code]....

View 1 Replies View Related

C/C++ :: Pass Values By Reference?

Nov 7, 2014

I built a program that finds the average amount of days missed per employee. I am now attempting to modify my program to pass values by reference rather than passing by value. I created 3 functions:

int numOfEmployees(); int numOfDays(int); double avgDays(int, int);

in the prototype I use the ampersand sign int numOfDays(int&);
in the actual function I use numOfDays(int& employees)

I am just not able to get the call to the function to work the program will crash when I modify it with the ampersand signs. I know I have to re-work my program, but I am having a hard time understanding how.

This is the original code I am trying to modify:

#include <iostream>
using namespace std;
int numOfEmployees(); //Prototype for numOfEmployees
int numOfDays(int); //Prototype for numOfDays
double avgDays(int, int); //Prototype for avgDays

[Code]......

View 1 Replies View Related

C/C++ :: How To Pass Multiple Values From One Function To Another

Mar 4, 2015

I need to pass multiple values from one function to another and how to do this. Here is my code so far.

#include <iostream>
#include <string>
#include <cctype>
#include <fstream>
using namespace std;
//Function Prototypes//
int charString(string, string, string);
string reverseString(string, string, string);

[Code]...

I basically need to take line1, line2, and line3 and return them to the reverseString function. Also, I am not allowed to do anything like make my own classes. I have to stick to the basics and no higher level programming techniques since we have not learned them yet.

View 5 Replies View Related

C++ :: How To Pass Structure Values Between Functions

Dec 29, 2012

Code:
struct NewPlayer {
int level;
int intelligence;
int damage;
};
int CharacterInfo(NewPlayer MageWizard, int Clevel,int Cint, int Cdam)

[Code] .....

View 1 Replies View Related

C :: Pass Values In Functions And Writing Them To A Txt File

Aug 23, 2013

This code is for fun, and have it doing a lot of what I want it to, just not all. I want random generated to write to a txt file. I tried to use an array but that failed. I wanted to use an array because i am only passing one value. Which makes sense since the random generated function is an int.

I made the fprintf as a comment but hopefully soon it will be able to send the values to the txt file. After that I will tackle the function.

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define HIGH 49
#define LOW 1
int random_generated()

[Code]...

View 11 Replies View Related

C :: Unable To Pass Values To Struct As A Byte

Jul 19, 2014

I am using a struct and tying to send values to it as byte value

Code:

#include<stdio.h>
typedef struct{
unsigned r1:1;
unsigned r2:1;
unsigned r3:1;

[Code] ....

Error: invalid suffix "b00100000" or incompatible types in assignment

I am able to access the member as Range.r1 = 1; and have no problems. I want to send data whole at once, but how ?

View 8 Replies View Related

C++ :: Pass 2 Arrays Into Void Function And Return Values To One Function?

Feb 12, 2014

I'm trying to pass 2 arrays into a void funtion, and return values to one function.

this is the the program I'm working with, after I'm done I have to split it into 3 files, a header, a main, and a separate cpp file for the functions to live in.

#include <iostream>
using namespace std;
void processArrary(int numberCount[], int Numbers[], int intnumberSize, int numberCountSize);
int main() {
int Scores[26] = {76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, 189};
int numberCount[8] = { 0 };

[code]...

The goal of this program is to separate and count the groups of numbers then output the amount of numbers in each group. Near as I can tell, everthing should work, but I'm getting all zeros to be displayed in each group.

View 6 Replies View Related

C++ :: What Is The Difference Between Pass By Reference And Pass By Pointers

Jan 23, 2013

I've been given an assignment with the below questions.

1. What is the difference between pass by reference & pass by pointers?

2. What is the use of the initialization list in the constructor?

3. What is meant by a reference & its advantage?

4. Class has a reference, pointer and a const. Is it possible to write the copy constructor & assignment operator overloading funciton? how? ( Since reference is there, I'm not sure on how to write for it)

5. Example for a variable decleration and definition? (I know for function but for variable don kw how)

6. static and const static what is the difference??

View 1 Replies View Related

C++ :: How To Access File Properties

Jun 29, 2014

Is it possible to access file properties from c++ program? For example, user could drag file to program and then it displays a detailed information about file like date modified, size, type and etc..

View 1 Replies View Related

C# :: Getting Properties From Different Classes / Objects

Feb 26, 2015

I have startes making a game where there is 3 ships that cross the screen verticaly, and the point is to shoot them down. So far I have actually managed to do this. I have also managed to add gamescore to the ships. But here is my problem, I cant find a way to combine the score from all three ships in to one score. I have all three ships in different classes, is that wrong? When I try to combine the scores, ship score1 cant see the other scores.

Do I need to somehow have all the ships in one class. Or are there a way to read the scores from three classes, and adding them up in to one in a new class?

One of the errors I get is "the name 'score1' does not exist in the current context.

View 14 Replies View Related

C# :: Use Of Auto-implemented Properties?

Jan 28, 2014

Code using auto-implemented property:

public class MyClass {
public int age { get; set; }
}
static void Main(string[] args) {
MyClass testing = new MyClass();
testing.age = 44;
Console.WriteLine(testing.age);
}

output: 44

Code using regular variable declaration:

public class MyClass {
public int age;
}
static void Main(string[] args) {
MyClass testing = new MyClass();
testing.age = 44;
Console.WriteLine(testing.age);
}

output: 44

Why use the auto-implemented property when you can just as equally use the second code block to achieve the same thing?

View 14 Replies View Related

C/C++ :: Adding Properties To A Class?

Jun 29, 2014

I had written a "DLL" in VB.NET a year or two ago to read and set MP3 tags. I want to write this exact same library in C++ so I can convert it in my droid project, and to get a hands on introduction to C++. So far this attempt has been a total mind melt!

I am finally wrapping my head around .cpp and .h files so there is light at the end of this tunnel. Here is my problem now:

I wrote the VB project with properties for each tag in the MP3 file, then I could get and set them - easy stuff.

When I try this in C++ I get compile error: a property can only appear within the definition of a managed type. I can usually stumble through Google searches and figure out this type of stuff on my own, but this one is stumping me -- I think I am missing some fundamental stuff here.

My code:

// MP3Tags.h
#pragma once;
#include <string>
using namespace std;
using namespace System::IO;

[Code]....

View 4 Replies View Related

C# :: Custom Control Properties?

Sep 23, 2014

I have been trying to make a custom control(list box with more features). I know how to setup custom properties, but how do I make it so that the property can be edited in a separate window ?

I think I figured out how to show the form itself, and I don't know how to make the [...] button like :

There's not much Custom Control tutorials out there, and that's really the problem here.

View 1 Replies View Related

C/C++ :: How To Change CMD Window Size (No Properties)

Oct 23, 2014

Is there any way to resize the cmd window?

Kinda like in properties, where you choose the height and width of the window, but in actual code. So everybody who open my program see the same window.

View 1 Replies View Related

C# :: Accessing GUI Properties From Application Object

Aug 20, 2014

I'm trying to get my head around threading and gui applications for fun, and I've ran into a problem I'm not too sure how to google it correctly or I don't understand the answers given. Basically I'm trying to access GUI item properties (add to a listview). I've been on stackoverflow alot, and I've noticed that accessing these properties is quite difficult. At least, I'm not really understanding how it is supposed to be done.

The following line gives me a null value.

frm.lstChat.Items.Add(newList);

From what I understand I need to access my form object instead of creating a new object window... but I'm not sure how to reference the initial form application.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Net.Sockets;
using System.IO;
using System.Threading;
namespace ModBot {

[Code] ....

View 3 Replies View Related

C++ :: Quicker Way To Configure Project Properties For Library?

Mar 4, 2013

I have to edit 4-5 lines in the debug, and then 5 lines in release for each of my little project's properties.

View 2 Replies View Related

C++ :: Design Own Container With Properties Of Both Vector And List

Dec 14, 2014

How can I write my own container which has properties of both vector and list.

E.g. I can access elements directly using [] operator like vector and behave like list in terms of memory (means we don't have to shift elements if we want to insert in between like list)....

View 1 Replies View Related

C Sharp :: How To Make Graph And Verify Its Properties

Apr 30, 2013

I want to make such application in which user make directed graphs along with relations between them. After that application show that which graph properties are proved in this graph e.g Reflexive, Irreflexive, Symmetric, Anti Symmetric, transitive etc

View 1 Replies View Related

C++ :: Difference Between Pass By Value And Pass By Reference?

Jul 2, 2014

// explain difference between pass by value and pass by reference

void addOne(int i)
{
i++;
}
void addOne(int& i)
{
i++;
}

View 2 Replies View Related

C++ :: Using A Textbox And Other Items Between Multiple Forms

Oct 31, 2013

I am writing a program in Visual C++ 10 with 2 forms.

In the first form I have a textbox and a button. The button opens the second form.

In the second form, I have a button that changes the text in the textbox in form1 to an item from a listbox in form2.

Here is my problem. When I do the code for the button in form2 to change the textbox in form1 I get the errors:

error C2065: 'textBox1' : undeclared identifier
error C2227: left of '->Text' must point to class/struct/union/generic type

I thought maybe I should just include the "Form1.h" file but I can't do that because I already included "Form2.h" in form1 in order to be able to open the second form. If I try to include form1 in form2, it says that the code to open form2 is an error now.

My question is, how can I access identifiers such as "textbox1" from other forms and other files when I already used the first form to open the second form? I also want to know how to do this for all identifiers between all files.

how to print the selecteditem from a listbox into a textbox because that doesn't work by just setting them equal either.

Here is my code:

#pragma once
#include "Form2.h"
namespace Test1 {
using namespace System;

[Code].....

View 11 Replies View Related

C Sharp :: Interact With Components From Other Forms

May 6, 2013

What I'm doing is giving the user the choice to show 2 different dates. 1 in yyyy-mm-dd notation and the other in dd-mm-yyyy notation.

I'm using a second form to do this.

So from Form1 I have my data in the datagrid and in Form2 I have 2 radio buttons giving the user the choice between Date1 and Date2. So how would I be able to interact with the first form with the radio buttons?

View 10 Replies View Related

C Sharp :: How To Use TabControl In Windows Forms

Apr 19, 2012

I want to display the related tab information in the same tab space provided in the TabControl.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved