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


ADVERTISEMENT

C++ :: Changing Object Property Through Console?

May 27, 2013

Working on a console application and I am trying to figure out a way that allows users to enter an object property along with a value. For example

HTML Code:

class Box {
public:
int height;
int width;
int length;

[Code] ....

For example if a user inputs "height" for Name and "13" as value I would like to find a way to change ab's height to 13. I want to make this work so that one can add another class and get the same functionality.

I tried looking online and I think maps are a way to do this and I tried doing that but I don't know how to proceed after/what code to write that would allow me to change it.

Note: I can't use if else statements or hardcoding to match the input to member as I want to make this extensible.

View 7 Replies View Related

C Sharp :: Unable To Successfully Submit List Of Authors From Listbox

Jan 17, 2014

I need to add either one author or a list or array of authors to my sql table. Here is the code that is used to insert the authors into the table:

The code from the listbox:

<asp:ListBox runat="server" ID="AuthorList" DataTextField="AuthorName" 
            DataValueField="AuthorName" DataSourceID="Authors"  SelectionMode="Multiple"/>    

Datasource code:

<asp:ObjectDataSource runat="server" ID="ds_InventoriedAuthors" 
SelectMethod="GetAuthors" TypeName="CntyLibrary.Inventory.Authors" InsertMethod="AddAuthors">
    <InsertParameters>
        <asp:QueryStringParameter Name="AuthorID" Type="Int32" QueryStringField="id" />

[Code] ....

View 3 Replies View Related

C# :: Moving Listbox Selection To New Listbox In New Form?

Sep 11, 2014

Okay so i have everything right accept transfering the selectedindex from listbox in form1 to listbox in form2. I am using the below string item to hold the selected line of the list box, with the intent of recalling and then adding it into the form2 listbox. I get a not implemented error and i can't figure out why. I know the information is moving with the variable item, it just doesn't get printed out to the new listbox.

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string item = listBox1.SelectedItem.ToString();
Form2 form2 = new Form2();
form2.Show(item.ToString());

[Code]....

View 13 Replies View Related

C++ :: Distributing Quantity R In M Boxes

Feb 24, 2014

I have an array of size m and r resources. What would be an efficient (or just any) way of distributing them in the way shown in the table? The highest amount of resources must be concentrated in the middle of the array and all the resources must be distributed.

I'm not really set on exactly how steep the "slope" must be, I just need a way of approaching the problem.

Example with m=9 and r=13

box resources
0 0
1 0
2 2
3 2
4 4
5 2
6 2
7 1
8 0

View 3 Replies View Related

C :: Change / Fill List Without Changing Function Type

Feb 13, 2013

I am an IT student currently learning linked list. I have a problem with my code here. After I call addFront() my list doesn't change when I display it. How do I somewhat change/fill my list without changing the function type? I know it works on pointers still messed up with linked list.

Code:

typedef struct node *nodeptr;
struct node{int item;
nodeptr next;};
typedef nodeptr List;
}

[code]....

View 3 Replies View Related

C++ :: Changing Address Value Of Head Node In Linked List

Jan 17, 2014

I am attempting to change the value of the head node in my list. I thought due to having pointer defined in parameter list I could change the address value of head node. The argument passed is a struct I did not have to use & in argument list to denote address of struct to compiler. This may have something to do with my problem. I did not include all routines called by main program just the deleteNode routine im having problems with.

bool deleteNode(struct node *head, struct node *delptr) {
node *cur = head;
node *tempNextptr= cur;
using namespace std;
while(cur) {
if (cur == delptr)

[Code] ....

View 1 Replies View Related

C/C++ :: Flow Meter - Count Certain Quantity Of Fluid Then Light Up Corresponding LED

May 6, 2014

I am attempting to write some code for a flow meter and LEDs using my Arduino. I need the flow meter to count a certain quantity of fluid, then light up an LED which corresponds to that quantity. I found this code on the internet and it was exactly what I needed but when I opened up the serial monitor to see if it worked it didn't. I have finally fixed the issue with it not counting anything at all, but it is still acting as if it was measuring the rate. how it counts and keeps track of how much fluid in total has passed through the flow meter ?

volatile int NbTopsFan; //variable to accumulate the number of pulses
float Calc = 0; //the volume flowed since measurement started, liters
void pulse() //This is the function that the interupt calls
int hallsensor = 2; //The pin location of the sensor

const int led1Pin = 3; //pin for LED corresponding to volume1
const int led2Pin = 4; //pin for LED corresponding to volume2

[Code] .....

View 13 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# :: 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 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++ :: 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# :: Using Array In Listbox?

Jun 2, 2014

My main form I have the following code

[ImportingConstructor]
public MainForm([ImportMany] IEnumerable<AudioPlugin> content)
{

[Code].....

However, when I add to the listbox as shown above in my main form code the results all show on the same line. My understanding was that they should all be treated as separate because of foreach loop but apparently that is incorrect. I have seen mixed things online some showing that its required to use AddRange instead of Add, however, after literally hours of trying to make this work I am still coming up with nothing. I can't seem to get any code to work using the AddRange or am I finding any way to output each results on a separate line.

View 7 Replies View Related

C++ :: Listbox SendMessage Not Working

Jun 25, 2013

I have a problem with SendMessage. Anything I send doesn't show up but instead empty lines appear. What is wrong with my code?

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR greeting[] = _T("Hello, World!");
wchar_t listBoxStr[15];

[code].....

View 7 Replies View Related

C# :: Invert ListBox Selection?

Apr 18, 2014

I have my ListBox working and I'm able to select the items I want to keep. I'm trying to now get the Invert of the current selection for the items to delete.

I tried using:

if (lstLinePatterns == null) return;
for (int i = 0; i < lstLinePatterns.Items.Count; i++)
lstLinePatterns.Items[i].Selected = !lstLinePatterns.Items[i].Selected;

But
.Selected
is giving me an object error.

Is there an easy way to just inverse current selection?

Current Code:

private void btnSelectNonRvt_Click(object sender, EventArgs e)
{
// Unselects any Items to Prevent Infinite Loop
lstLinePatterns.SelectedIndex = -1;

[Code]....

View 3 Replies View Related

C# :: Clear A Listbox From A Class?

Jun 5, 2014

I need to clear a listbox from a class other than the form where it exists. Why this isn't working? I'm getting no error messages when I compile and I am seeing the Console.WriteLine text I also added in the same function. I can call this function from within my form and it behaves as expected. I tried setting the listbox to public despite the fact I wasn't getting protection level errors but that made no difference.

Just to clarify what I'm doing here... I have a form that includes a panel of user controls from another class. So there is a listbox on OtherClass and the listbox is in MyForm. Heres my code:

MyForm

public void ClearListBox() {
Console.WriteLine("echo");
listBox.Items.Clear();
} OtherClass
private void listBox_SelectedIndexChanged(object sender, EventArgs e) {
MyForm mf = new MyForm();
mf.ClearListBox();
}

View 9 Replies View Related

C# :: Two Checked Listbox - One Interacts With Other

Aug 31, 2014

I am working on a Windows From application on Visual Studio 2010 where i need to use two checkedlistbox that interacts one with the other one. Let say that the first checkedlistbox is for world regions (i.e.):

Asia
Africa
Europe
South America

And let say that the second checkedlistbox is for Countries (i.e.):

Spain
Italy
Romania
Monaco

(all of this belongs to Europe region)

What we need to do is that when the user check on any world region it automatically checks all the countries on that region in the second checkbox, and vice versa if the users check any country on the second checkedlistbox it automatically seconds the region on the first one.

I know that is possible in Java and we know how to do it, but i don't know if C# supports this and how to do it. I was looking on the class information in the microsoft website: [URL] .... but not a concrete example on how to do it.

View 5 Replies View Related

C# :: Listbox Loop - Getting Value Of Both Cards

Apr 3, 2015

I have a lstYourHand that has two cards in it, I loop through the listbox to get the values of both cards. I take the string value of the listbox item (strCardVal) and use a switch to give it an integer value (intCardVal). For some reason, when I run the code, the message Box at the end gives me the value 0 as a result, it does not register me giving it a value in the switch statement. My code is below:

Int32 intCardVal = 0;
String strCardVal;
Int32 intLoopCounter1;
for (intLoopCounter1 = 0; intLoopCounter1 == 1; intLoopCounter1++) {
strCardVal = lstYourHand.SelectedItem.ToString();

[Code] .....

View 3 Replies View Related

C# :: Removing Items From ListBox

Mar 5, 2014

I'm working on creating a windows form with a listbox, textbox, and 2 buttons (add,remove). I need a way of removing every string matching the contents of the textbox from the listbox. Here's what I have:

for (int i=0;i<listBox1.Items.Count;i++)
{
//...
listBox1.RemoveAt(i--)
}

Seems to work, but I need a way to show a error message once the user clicks 'remove' and no items in the listbox match.

View 6 Replies View Related

C# :: Cannot Set Font Size For A Listbox

Jun 24, 2014

I was working with a richTextBox on setting its font, color and size. I found examples and got that to work. It seems like a kludge to me just to get the size set.

So, now I need to do the same for a listBox. I got the font and color set but cannot get the font size set.

The error I am getting is on line 6 below: listBoxTopLevelChecklist.Font.Size = fontDialog.Font.Size;

VS 2013 Express tells me this property (font.size) is read-only. That was the same error I got on the richTextBox until I found way using the .SelectionFont structure, but the listBox doesn't support that. So, I'm stuck.

Line 8 on is working finr for the richEditBox.

DialogResult result = fontDialog.ShowDialog();
if (result == DialogResult.OK) {
listBoxTopLevelChecklist.Font = fontDialog.Font;
listBoxTopLevelChecklist.ForeColor = fontDialog.Color;
listBoxTopLevelChecklist.Font.Size = fontDialog.Font.Size;

[Code] .....

View 2 Replies View Related

C# :: Change Listbox Color?

Dec 22, 2014

I've changed the listbox foreground color to default application background color so I get: [URL] which is fine but when I select any element I get white background/foreground(or whatever it is): [URL]

How can I change this so I will have the same default color in the second case?

It is a windows store app

Xaml code(listbox is at the end):

<Page
x:Name="pageRoot"
x:Class="ExchangeRate2.MainPage"
DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"

[Code]....

View 1 Replies View Related

C# :: ListBox Values And Arrays?

Sep 18, 2014

I'm making a simple airline reservation. I have two list boxes one has the section (A, B, C, etc) and the other rows (1, 2, 3, etc). I used two different arrays to put the values into the list box via form unload. The problem I can't seem to figure out is how can I update these seats and inform the user if a seat is taken or not. Lets say a customer takes A-1 (only seat taken). If I try to add someone else there it will inform me that seat is taken and to select another one. If all the seats are taken it'll tell me to put customer into the waiting list.

Also one more thing is that each row has 3 seats, so A-1, A-2, A-3 for example. If say A-1, A-2 are taken when I push a button show remain seats it should show A-3 only. I have a lot od struggle using arrays.

View 3 Replies View Related







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