Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here,
Anyone help me

let me start from first,

in my wpf application, i want to generate bill of item list, so when i choose item by item id with the help of Textbox then item name show on label in ITEM_Name Column and also its item category show on other label in ITEM_Categoty. and in this item list 16 rows will be show .

show Question is that ....
does all textbox textchange event have to make in .cs file or any else solution is for that

one more question is how can i group as category viz

(sorry for bad English)
Posted

1 solution

Yes, all of the C# code has to be inside the .cs (Class) file. Where you would handle and execute tasks in your applications.

Even if you write the XAML code for the TextChanged event as

HTML
<textbox textchanged="eventhandler" />


.. the code would still call the eventhandler from the code-behind. MSDN documentation[^] for TextChanged.

You can group the TextBox by adding them inside a StackPanel. That StackPanel would contain all of the TextBox relative to each other, in it.

You can have multiple TextBox controls in your application, like this

HTML
<TextBox Name="first" TextChanged="eventhandler"  />
<TextBox Name="second" TextChanged="eventhandler"  />


.. and they would both have an event handler like this

C#
void TextChanged (object sender, EventArgs e) {
   // handle the event here, 
   // now since both are sending the request here..
   // you can get their property of Name and continue the programming

   // Convert the event trigger control to a TextBox
   TextBox textBox = sender as TextBox; 
   // Read the name property
   string name = textBox.Name;
   // run the condition and execute your code, lets alert
   if(name == "first") {
     MessageBox.Show("First textbox value was changed.");
   } else {
     MessageBox.Show("Second textbox value was changed."); 
   }
}
 
Share this answer
 
v2
Comments
mukesh mourya 16-Nov-14 11:08am    
here , my project have 16 textboxes ,does all textbox has textchanged Event to print item name on label ...?
Afzaal Ahmad Zeeshan 16-Nov-14 13:12pm    
Yes, they all have their own TextChanged event. Which can be hanled for themself. :-)
mukesh mourya 16-Nov-14 13:33pm    
is this possible to know which textbox textchanged event fire using this keyword in using same function
Afzaal Ahmad Zeeshan 17-Nov-14 10:12am    
You can check that inside a condition, by giving a name to each of your TextBox and then checking that name. I will update my answer for this. :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900