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
Please visit this tutorial to see how to create setter and getter Ted Kolovos - Amazing ASP.NET Class properties - accessor Methods - getters and setters
Weird algorithmCode: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;![]()
the way Set , Get Accessors work are like the code below
the highlighted code in red ,that's missing in your code.Code:private string _myname; public string myName { get {return _myname ; } set { _myname = value ;} }
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]
@jokujames thank you @abdul thank you
could someone telll me how to use isort, icomparable and iequitable???
sorry bout that gokujames haha **** i need to include the Icomparable to my windows app
my bad it was Iequatable not equitable lol please someone help me
I don't want to give you the solution but here take this and move along from here,,
IEquatable(T) Interface (System)
How to use the IComparable and IComparer interfaces in Visual C#
Learn Interfaces ,as they are key to making good programs![]()
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);
I guess this is what you are trying to do ;
in short this the code that you all need to write ,in a straight forward manner.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;
Code:txtTotalPrice.Text -= ListBox1.SelectedValue;
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks