Jump to content

help

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
21 replies to this topic

#1
nero29

nero29

    Newbie

  • Members
  • PipPip
  • 12 posts
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?

#2
abdul.gafur

abdul.gafur

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
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
nero29

nero29

    Newbie

  • Members
  • PipPip
  • 12 posts
@abdul i have already created a program.
Posted Image
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
nero29

nero29

    Newbie

  • Members
  • PipPip
  • 12 posts
help everyone

#5
nero29

nero29

    Newbie

  • Members
  • PipPip
  • 12 posts
guys could someone tell me how do i refresh my combobox and clear it? cause whenever i use combobox1.clear() it doesnt work

#6
gokuajmes

gokuajmes

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 518 posts
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
abdul.gafur

abdul.gafur

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts

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
gokuajmes

gokuajmes

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 518 posts
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
 ComboBox1.Items.Clear();
ComboBox1.DataSource = DataAccessLayer; //you need to figure the data logic to use
ComboBox1.DataBind();


#9
nero29

nero29

    Newbie

  • Members
  • PipPip
  • 12 posts

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

 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
gokuajmes

gokuajmes

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 518 posts
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 ]

#11
nero29

nero29

    Newbie

  • Members
  • PipPip
  • 12 posts

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 ]

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
abdul.gafur

abdul.gafur

    Learning Programmer

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

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