C# :: Sharing Item List Object Between Two Forms

Nov 4, 2014

I've changed up my code to the retail checkout WFA I am trying to make. I have an item list filled with objects of the now globally accessible 'Item' class, but I'm having trouble.

Essentially, I want to send an object of the item class chosen from a dropdown menu to form2, where I will fill in certain blank attributes with data entered in form2's text boxes and comboboxes. The problem, it seems, is I need another itemlist in form2 that will hold the object being passed to form 2, so I can then pass all the information to textboxes on form3 (the receipt/review page). It's been more than a year since I coded with C#, and I've forgotten quite a bit. I was also not able to find any tutorials on building an item list without an associated combobox or droplist, which is what I need.

This is my item class (minus most of its properties so the page doesn't stretch).

class Item {
public string prodName;
public string fName;
public string lName;
public string ccNum;
public string ccProv;
public string shipAddr;

[code] ....

For anyone who didn't see my last question, I'm in a User Interface Design class, not a C# class. I know this probably isn't the best code out there, but for my purposes the program just needs to compile beginning to end and pass the data like it should.

View 1 Replies


ADVERTISEMENT

C# :: Get Item From List In Another Class

Jan 15, 2014

How can I get the items from a list into textboxes. I am doing an windows form application in visual studio.

I have the first form with a couple of textboxes.

I want the inputs be saved in a list. And then displayed in another form. How to move on. The class with the list looks like this:

public class Casecs {
public List<caseInformation> fallInformation = new List<caseInformation>();
public class caseInformation {
public string caseId { get; set; }
public string phoneNumber { get; set; }
public string description { get; set; }
}

Then the form with the inputs in textboxes looks like this:

Casecs Casecs = new Casecs();
Casecs.fallInformation.Add(new ERIS.Casecs.caseInformation {
caseId = txtCaseId.Text,
phoneNumber = txtPhonenumber.Text,
message = txtMessage.Text
});

Then where I am stuck a form with some textboxes where I want the list items to be displayed:

public partial class btnDispatch : Form {
public btnDispatch() { }
public btnDispatch(List<Casecs.caseInformation> fallInformation) {
InitializeComponent();

View 7 Replies View Related

C# :: Create A Button For Each Item In A List

Jan 26, 2014

Basically, the program is just sort of a soundboard. The way it is now, it just reads all the names of the files in a particular folder (all .wav files), and then adds an entry to a listBox for each file found. What I would like to do, is instead of a listBox, have buttons for each one. Is there any way to iterate through a list of items and create a button for each one? The main problem I see is placing the buttons. It would have to have some sort of grid to place them in I would imagine...

View 3 Replies View Related

C++ :: Removing First Item From Single Linked List

Oct 10, 2013

My algorithm is not working

void remove_first() {
current_node = head_node;
node * temp_node = current_node;
current_node = current_node->get_next();
head_node->set_next(current_node);
delete temp_node;
temp_node = NULL;
}

View 2 Replies View Related

C/C++ :: Linked List Insert Item Function

Oct 14, 2014

It is suppose to insert items in Linked List in sorted ascending order and no duplicates are allowed.The code complies but it creates duplicates out of order.

ListRetVal CSortedList :: InsertItem(const ListItemType &newItem)
{
ListItemNode* newLNode = new ListItemNode();
newLNode->value=newItem;
newLNode->next=NULL;

[Code].....

View 5 Replies View Related

Visual C++ :: Get The Path For A Selected Item In A List Control?

Jan 29, 2013

How do I get the path for a selected item in a list control?

View 5 Replies View Related

C# :: Open WPF Window From Double Click On Selected Item In A List?

Apr 23, 2015

I have a list with 2 items in it. When I double click on item 1, I want to open Window1.xaml, when I double click on item 2, I want to open Window2.xaml...

The code below works for popping up a message box, or window for that matter. But I really need to get the Window1 and Window2 based on the clicking of the correct selected item in the list.

Here is some code:

<ListView d:DataContext="{d:DesignData }" Name="PharmacyLv" IsSynchronizedWithCurrentItem="True" l:Sortbehavior.CanUserSortColumns="true" >
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<EventSetter Event="MouseDoubleClick" Handler="ListViewItem_PharmDoubleClick" />
</Style>
</ListView.ItemContainerStyle>

[code].....

View 3 Replies View Related

Visual C++ :: Enable / Disable Menu Item 2 In OnUpdate Handler Of Menu Item 1?

Sep 15, 2014

I have two menu items. When item 1 is disabled, I want item 2 to be disabled as well. In the OnUpdate handler of menu item 1, I have tried to use "t_pMenu = pCmdUI->m_pMenu;", "t_pMenu = pCmdUI->m_pSubMenu;" and "t_pMenu = pCmdUI->m_pParentMenu;" but I always get NULL t_pMenu. How can I achieve this purpose?

Code:
void CDummyView::OnUpdateMenuItem1(CCmdUI* pCmdUI)
{
if(m_bShowMenuItem1) {
pCmdUI->Enable(TRUE);

[Code]....

View 14 Replies View Related

C++ :: Eliminating False Sharing With TBB

Nov 9, 2013

So, as the title says, I'm trying to eliminate false sharing, or, eliminate sharing writes between threads with TBB. The question is how.

Normally I'd make an array whose size is equal to the number of threads, then locally write to a local variable and update the array only at the end of the thread.

But, of course, I cannot seem to get either thread id or total number of threads TBB uses. I found a reference to tbb::enumerable_thread_specific, which as I understand, is supposed to work for exactly this. But as soon as I added it, it hurt performance by ~60% instead of making it better.

How to do this properly? You don't really need to look so hard on how the algorithm works (I don't know either). I know it's not quite right right now due to race conditions, but I'll fix that later. I used a reference implementation that I copied™, and my task is to parallelize it.

The parts where the problem is right now is in red (of course, it's not all problems; it's only a subset of them).

Code:
#include <iostream>
#include <vector>
#include <fstream>
#include <ctime>
#include <algorithm>

[Code] ....

View 11 Replies View Related

C++ :: Sharing Data Between 2 Files

Aug 30, 2013

The problem is I have a function which sets some variables and I want to access the variables, but myfunc() is nested too deeply for me to pass a data structure all the way down and to return all the way up. The functions reside in different files. I'm not allowed to use extern structs (i.e. a global variable).

How to use a class and instantiate it in myfunc(). My solutions are:

- using the singleton class method
- static variables and function residing in the class (but I'm suspicious of this way. seems like it's just class variables masquerading as global variables.

View 2 Replies View Related

Visual C++ :: 2 Programs - 1 Dll Sharing Variable?

Mar 16, 2014

my goal:

have 1 program handle the UI

have that program store variables to a DLL

have the 2nd program grab the stored variables to reform some number crunching, without interfering with the UI program, and once done, have it drop the answers back into that DLL, so that the UI can grab it when it's ready.

I have made the 2 programs, + dll

What I've Achieved:

the first program accesses the dll, and loads up a variable (and stays connected to the dll, so that the Dll instance doesn't reset)

I've gotten the DLL to output the variable to make sure it's received it, and stored it to it's own global variable.

the second program connects to the dll successfully, but when it tries to retrieve the data, it returns 0's (NULL's)

My research:from what I've read, so long the dll is connected to a program, all additional programs will attach to the same instance.

how do I make the global variable in the dll be accessible to both programs? (without resorting to saving it to the HDD Idealy)

View 7 Replies View Related

C++ :: Sharing A Program - Sending Executable Files

May 22, 2013

I am just wondering if it is possible to send a project to someone via email - In a simple way, almost like you would install software from the internet, maybe a setup file, or something. The compiler I use "Dev C++" creates a .cpp file and an executable. Unfortunately, I cannot send that .exe file. How would you recommend sharing a program?

View 5 Replies View Related

C :: 3 Students Sharing Their Meals - Settle Bills Equally

Sep 28, 2013

There are 3 students (0=John, 1=Peter, 2=William) sharing their meals. Who does the cooking, does the shopping and pays for the bills. End of the month they sum it all up and settle the bills equally. Who must pay the most is outputted at the top, while the person that collects most is at the bottom. Students that have to pay the same amount are listed in the same order as they are ordered in the input. (receiving same amount, the same). Total of the settlement are rounded to whole cents. Sometimes they loose a cent, sometimes they gain one.

So I started making a plan what the program is supposed to do. Pen and paper:

1. Sum of the total amount from all the meals.
JohnPaid+PeterPaid+WilliamPaid=Total
Total / 3 = FairShare

calculate difference of all three the students

if JohnPaid == FairShare
print John receives 0.00

if JohnPaid > FairShare
print John receives difference

if JohnPaid < FairShare
print John pays difference

etc. (same for Peter and William)

Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

/* type definition of student */
typedef struct student {
int who; /* 0=John, 1=Peter, 2=William */
float paid; /* amount that student paid */

[Code] .....

Example in/outputs:

<0 39.85>
<1 30.83>
<2 35.43>
Peter pays 4.54
William receives 0.06
John receives 4.48

<1 106.32>
<0 88.14>
<2 88.14>
John pays 6.06
William pays 6.06
Peter receivers 12.12

Looking at this code, I see a lot of global (general) variables. Do I need to adjust this skeleton code I received or should I just add code?

View 6 Replies View Related

C++ :: Add Constant Object To Linked List Of Objects

Feb 10, 2014

I have a standard linked list in template format (with T being the typename) with the following relevant insertion operators:

bool PushFront (const T& t); // Insert t at front of list
bool PushBack (const T& t); // Insert t at back of list

I want to build a list of pointers to objects (we'll call them objects of class Box for simplicity) that is member data for a parent class (we'll call that class Warehouse). However, I want to have a constant Box....const Box INVISIBLE_BOX = Box(); that represents a nonexistent Box. However, I cannot use either

PushFront(&INVISIBLE_BOX)
or
PushBack(&INVISIBLE_BOX)

to add INVISIBLE_BOX to the list of boxes without getting an invalid conversion error invalid conversion from âconst warehouse::Box*â to âwarehouse:: Box*â [-fpermissive]

What can I do to make it take a constant Box? I am using g++ to compile these files.

View 1 Replies View Related

C/C++ :: Object Is Being Added To A List Multiple Times?

Nov 6, 2014

I've been struggling with an object when trying to add it to a list with [Listname].push_back. You see, I have a list with some objects that will be rendered in the screen (Called objects) and a function to create a text box with some text. The function in question is the following:

void reprEv(int evNum, ALLEGRO_BITMAP *txtbxim) //Event to call, default text box image.
{
textBox *txtBox = new textBox("Line 1 ", "Line 2 ", "Line 3 ", "Line 4 ", "Line 5 ", textboximage);
objects.push_back(txtBox);

[Code]....

(txtNum is increased then space is pressed, and when certain screen (maxScreen) have been shown, then it will go to the playing state)

My problem begins when the text box is created, because it's supposed to add only 1 text box to objects list, but instead adds hundreds of text boxes to objects.

View 1 Replies View Related

C# :: List Initialize In Object Initialization Method

Oct 31, 2014

public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public List<Order> Orders { get; set; }
public Customer() {
Orders = new List<Order>();
}
}

This object is called as

var cust = new Customer
{
Id = 1, Name = "Khatana", [b]Orders.Add(new Order())[/b]
}

I want to ask, Orders.Add(new Order()) is a wrong way, but why..!!... as List<Order> already has been initialized in Customer constructor, then why it is again required to be initialized in object initialization.
Is this a correct way

List<Order> orders = new List<Order> {aaa.....bb....cc};
var cust = new Customer
{
id = 1, Name = "Khatana", Orders = new List<Order> { orders }
}

Why we need to initialize a list in an object initialization, where as the list has been already initialized in object constructor.

View 2 Replies View Related

C# :: How To Send Message To Multiple Sockets In List Object

Oct 7, 2012

Have tried to track down the delay? Which function takes that long? Have you printed some logs or measured the time of the functions? No I am not sure how to do that! I debugged it but i didn't see any difference! I definitely think its the logic in the receive code that's "inefficient" what do you think about that? Do you think there's a more efficient way of receiving messages and sending them? Because what I am doing is receiving one then calling send and sending that message out to all users then receiving another one then calling send and sending it out to all users and repeating that process till all the messages are sent, both methods are using a loop to send to all users. DO you think i should receive all messages then send them all out at once? or is that less efficient?

View 4 Replies View Related

C++ :: Unable To Modify Object Data In Linked List

Apr 14, 2014

I'm having a problem trying to modify my patient's data. It seems to work, but once the block of code ends it does not save to the linked list.

Problem located in case M.

linked list template header: [URL] ...
patient header: [URL] ...
patient implementation: [URL] ...

#include <iostream>
#include "listTemplate.h"
#include "PatientRecord.h"
using namespace std;
char menu() {
char input

[Code]...

View 1 Replies View Related

C# :: Changing Quantity To List Object In Listbox Checkout

Apr 9, 2014

i have a program that is a Mediastore and i have 4 classes. Produkt: which is a class with a few variables that i use to add products to my List.

public class produkt
{
public string Name;
public string price;

[Code]....

then i have my Lager class which i use to add my products to my list and Listbox. This is done by having 3 textfields where i say what the Name,SerialNumber and Price of the object i created should have.

In this class i also have 2 more textfields and a button that make it possible to add a quantity of the selected listbox object of my product Class. if the item im trying to add a quantity to dosent exist i get a question if i wanna add that product and it adds that product to the list. if however the product allready exist its suposed to add the quantity with the selected amount from my textbox.

Then I have my Class Kassa which is a Form with 2 Listboxes. The first listbox share the same List as the one in my Lager class and the other listbox is the listbox which i use to take items from my produktlist and put it in my checkout "basket" then i am suposed to be able to choose one of these items from my checkout basket put the amount i want of that item into a textfield called KvantLEv and press the checkout button to be able to simulate a checkout and then this selected item's quantity is suposed to be lowerd by the specified amount and is to be removed from the checkoutlistbox but this aint working... this is my checkout function so far

private void cashout()
{
produkt p = new produkt();
int a = VaruKorg.Items.Count - 1;

[Code]....

View 7 Replies View Related

C++ :: Input Data Of Object From User And Then Insert It In Linked List

May 16, 2013

Error:
--------------------Configuration: nc - Win32 Debug--------------------
Compiling...
cv.cpp
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/nc.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

nc.exe - 2 error(s), 0 warning(s)

Compiles with 0 error but on running 2 Errors appear.

I'm Inputting data of an object from user and then inserting it in the link list.

#include <iostream>
//#include <fstream>
using namespace std;
#define LEN 100
////////////////////////////////////////////////////////////////////////////////////////////////////
class employee{

[Code] ....

View 1 Replies View Related

C++ :: List Of Objects - Read Information From Each Object To Compare To User Input Prompt

Apr 19, 2013

I have a list of objects that I need to read information from each object to compare to a user input prompt.

#include "Passenger.h"
#include "Reservation.h"
#include "Aircraft.h"
#include <iostream>
#include <fstream>
#include <string>
#include <list>
using namespace std;
//Function Prototypes
void flightRoster(list<Reservation>&);

[Code] ....

View 1 Replies View Related

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++ :: 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# :: 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 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







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