Closed Thread
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: help

  1. #11
    nero29 is offline Newbie
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Re: help

    Quote Originally Posted by gokuajmes View Post
    So you say you are a Newbie and you managed to create that application
    anyways let me write you a better explanation after i come from work,if that is ok with you

    by the way post the code / the place only where its not working ,a line or 2 above and line or 2 below the error causing statement.[Dont post the whole code ]
    hahaha i mean i am just a first year IT student
    so i am not that good hahaha anyways could you tell me how to put the price in my items cause i dont know how they will automatically appear if i choose the items in the artist combobox my prof told me to use geters and setters but everytime i use this code
    :
    get { return value; }
    set
    {
    if (value == 0)
    {
    price = 0;
    }
    else
    {
    price = value;
    }
    }


    i get an error like ;expected thing

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #12
    abdul.gafur's Avatar
    abdul.gafur is offline Learning Programmer
    Join Date
    Mar 2010
    Location
    Salo, Riau, Indonesia
    Posts
    42
    Rep Power
    0

    Re: help

    Please visit this tutorial to see how to create setter and getter Ted Kolovos - Amazing ASP.NET Class properties - accessor Methods - getters and setters

    Code:
    if (value == 0) {
       price = 0;
    }
    else {
       price = value;
    }
    
    //why don't you just make like this :
    price = value;
    
    // Although value==0, but price = 0 or price = value;
    Weird algorithm

  4. #13
    gokuajmes's Avatar
    gokuajmes is offline Programming God
    Join Date
    Jan 2010
    Location
    India
    Posts
    516
    Blog Entries
    5
    Rep Power
    12

    Re: help

    the way Set , Get Accessors work are like the code below

    Code:
    private string _myname;
    public string myName
    {
     get {return _myname ; }
     set { _myname = value ;}
    }
    the highlighted code in red ,that's missing in your code.

    WorkFlow :

    1.Add a combobox in your Windows form by double clicking it in toolbox or drag and drop it.

    2.Add items to the combobox using the Gui , Items.Add ( ) method or better the Items.AddRange ( ) method of the ComboBox class.

    3.Now double click the combobox to go into the code ,automatically a event is created for the 'Selected Index changed '

    4.In that this is what you have to do

    Code:
    myPriceTextBox.Text = ComboBox1.SelectedIndex.Value.ToString() ;
    or
    myPriceTextBox.Text = ComboBox1.SelectedValue.ToString();
    //always make sure that selected index is "not out of range " ie..  [ ! = -1]

  5. #14
    nero29 is offline Newbie
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Re: help

    @jokujames thank you @abdul thank you
    could someone telll me how to use isort, icomparable and iequitable???

  6. #15
    gokuajmes's Avatar
    gokuajmes is offline Programming God
    Join Date
    Jan 2010
    Location
    India
    Posts
    516
    Blog Entries
    5
    Rep Power
    12

    Re: help

    ooh by the way that's not jokujames but Gokujames
    i am sure i have seen the Icomparable as a Interface ,but ISort & IEquitable . Anyway have a look at what IComparable interface is
    help-.png

  7. #16
    nero29 is offline Newbie
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Re: help

    sorry bout that gokujames haha **** i need to include the Icomparable to my windows app

  8. #17
    nero29 is offline Newbie
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Re: help

    my bad it was Iequatable not equitable lol please someone help me

  9. #18
    gokuajmes's Avatar
    gokuajmes is offline Programming God
    Join Date
    Jan 2010
    Location
    India
    Posts
    516
    Blog Entries
    5
    Rep Power
    12

  10. #19
    nero29 is offline Newbie
    Join Date
    Mar 2010
    Posts
    12
    Rep Power
    0

    Re: help

    bro could you tell me wats wrong with my code how come when i delete the item on the list box the price doesnt subract correctly from the total amount
    int index = listBox1.SelectedIndex;
    int i = -1;

    listBox1.Items.RemoveAt(index);
    totalAmount = totalAmount -= priceTab[i];
    textBox6.Text = string.Format("{0:#.##}", totalAmount);

  11. #20
    gokuajmes's Avatar
    gokuajmes is offline Programming God
    Join Date
    Jan 2010
    Location
    India
    Posts
    516
    Blog Entries
    5
    Rep Power
    12

    Re: help

    I guess this is what you are trying to do ;

    Code:
    // you have a button that Invokes the event to decrease the Price.So under the Button click event write the code
    
    //Decrease the current deleted products Price from the textbox that has the total price and then update the value
    
    //get the value of the price from the ListBox
    string priceToDelete = ListBox1.SelectedItem.Value ;
    
    //get the Total price from the TextBox
    string total = txtTotalPrice.Text ;
    
    //deduct the product ammount and then update
    total -= priceToDelete;
    txtTotalPrice.Text = total;
    in short this the code that you all need to write ,in a straight forward manner.

    Code:
    txtTotalPrice.Text -= ListBox1.SelectedValue;

Closed Thread
Page 2 of 3 FirstFirst 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts