help regarding our project my professor ask us to make a project. i have created a windows application but duno how to implement the code. this is wat i want to do. in the combobox if you select the item then the price should also appear automatically in the text box how am i going to code that?
help
Started by nero29, Mar 12 2010 02:41 AM
21 replies to this topic
#1
Posted 12 March 2010 - 02:41 AM
|
|
|
#2
Posted 12 March 2010 - 02:56 AM
This forum is not to do your job, but to help you, try to start create that program, if you have trouble, we will help
#3
Posted 12 March 2010 - 04:14 AM
@abdul i have already created a program.

i want to know how to do it i mean i duno wat to put on the event. cause this is wat i want to do when u choose an item in combobox the price should automatically appear how do i do that?

i want to know how to do it i mean i duno wat to put on the event. cause this is wat i want to do when u choose an item in combobox the price should automatically appear how do i do that?
#4
Posted 12 March 2010 - 04:53 AM
help everyone
#5
Posted 12 March 2010 - 05:51 AM
guys could someone tell me how do i refresh my combobox and clear it? cause whenever i use combobox1.clear() it doesnt work
#6
Posted 12 March 2010 - 08:32 AM
Ok the code goes like this have a neat look
//Event handler for Dropdownlist selected index change
public void myDropDownList_SelectedIndexChange(Object sender,EventArgs e)
{
//check if use has selected nothing
if( myDropDownList.SelectedIndex ! = -1)
{
//if the user has selected something then we enter the if, assign the selected value of the drop down into the text box.
TextBox1.Text = myDropDownList.SelectedValue.ToString() ;
}
}
#7
Posted 12 March 2010 - 09:05 AM
nero29 said:
guys could someone tell me how do i refresh my combobox and clear it? cause whenever i use combobox1.clear() it doesnt work
try this :
combobox1.Items.Clear(); combobox1.SelectedIndex = -1; combobox1.Text = "";
But, I've never tried before. I don't have c# IDE or something like that
#8
Posted 12 March 2010 - 09:12 AM
I am sure ,that you got something wrong with the syntax or referencing the wrong comb box it happens you know even with the experienced developers:sneaky:
try the code below
try the code below
ComboBox1.Items.Clear(); ComboBox1.DataSource = DataAccessLayer; //you need to figure the data logic to use ComboBox1.DataBind();
#9
Posted 12 March 2010 - 04:46 PM
gokuajmes said:
I am sure ,that you got something wrong with the syntax or referencing the wrong comb box it happens you know even with the experienced developers:sneaky:
try the code below
try the code below
ComboBox1.Items.Clear(); ComboBox1.DataSource = DataAccessLayer; //you need to figure the data logic to use ComboBox1.DataBind();
i am sorry i am just a newbie i dont know how to make this code work. the DataAcessLayer part wats that? cause i get some error regarding that one and also the databind code :P sorry i am just a newbie. if you want i will post my codes here for you guys to check wats wrong with my code :P
#10
Posted 12 March 2010 - 05:46 PM
So you say you are a Newbie and you managed to create that application :sneaky:
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 ]
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 ]
#11
Posted 12 March 2010 - 07:43 PM
gokuajmes said:
So you say you are a Newbie and you managed to create that application :sneaky:
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 ]
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 :P
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
#12
Posted 12 March 2010 - 09:49 PM
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 algorithm :P
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 :P


Sign In
Create Account


Back to top









