I have made a delete/clear button that works, but after using it I cannot make a new search...I also have a refresh button that doesn't work at all. I want to be able to make a ned search and I thought I could use the refresh button for this.
Can you help me? If you can, please explain it for me with an example.
private void Button_Click(object sender, RoutedEventArgs e)
{
dataGridTest.ItemsSource = null;
}
private void Refresh_Click(object sender, RoutedEventArgs e)
{
dataGridTest.Items.Refresh();
}
There's some part of your code that we need to see so that we can able to help. But if you are working with WPF, WPF is awesome with MVVM Design pattern.
You can check some start up here.
Josh Smith's tutorial is the best tutorial about MVVM.
Related
I've tried many methods to try and get this to work, but have had very little success making it stable. What would be a good way of going about this?
When I click the first button I can view my first panel just fine, but it permanently hides the second panel despite me click button 2 which in theory should unhide the first panel and and show the second one. I'm guessing this method is outdated. I should note that both panels are directly on top of each other. If anyone has a solution to this please let me know.
private void button1_Click(object sender, EventArgs e)
{
firstPanel.Show();
secondPanel.Hide();
}
private void button2_Click(object sender, EventArgs e)
{
secondPanel.Show();
firstPanel.Hide();
}
I have been developing a windows form application and ran into a problem.
After trying various things (Listed below) I have come to seek your knowledge to help point me in the right direction.
I have replicated a much simpler version of my program:
As you can see, I have two textboxes. I want to be able to click on the textbox on the bottom (textbox1) and call some form of an event, in this case, for simplicity, pop up a message box.
I have been through the events listed here:
https://msdn.microsoft.com/en-us/library/system.windows.forms.textbox_events(v=vs.110).aspx
And implemented them into my code as I expected one of them to work. However, this is not the case.
private void textBox1_TextChanged(object sender, EventArgs e)
{
MessageBox.Show("TextBox Entered");
}
//Above - Will pop message box when text entered.
private void textBox1_GotFocus(object sender, EventArgs e)
{
MessageBox.Show("TextBox Entered");
}
private void textBox1_Enter(object sender, EventArgs e)
{
MessageBox.Show("TextBox Entered");
}
private void textBox1_Click(object sender, EventArgs e)
{
MessageBox.Show("TextBox Entered");
}
Does anybody know what I am missing? I presume what I am trying to achieve is actually possible?
Kind Regards,
B.
Ensure the event is subscribed to the methods you have written. You can do this in the design view using the Events tab of the property window (looks like a lightning bolt). As mentioned by others, a double click in the events window will generate the event's method for you, and subscribe to it automatically.
Another way is to subscribe directly using code; you could write this in the form constructor for example:
textBox1.TextChanged += textBox1_TextChanged;
I am very new with the C# UserControl. I have problems with the event Leave. This is my situation: I would like to go from usercontrolA to userControlB. Before going to userControlB, usercontrolA_Leave event is called.
private void usercontrolA_Leave(object sender, EventArgs e)
{
MessageBox.Show("you are leaving.....");
}
After MessageBox is shown, the program will not proceed to my userControlB. HOWEVER when there is no MessageBox in the code, the program can proceed to userControlB.
private void usercontrolA_Leave(object sender, EventArgs e){//anything but MessageBox}
In my case, I need MessageBox.
I need MessageBox(or other thing) for me to decide whether staying or leaving.. .
msdn Control.Leave Event
I heard about setting set focusor lost focus. Is that possible to use this?
I hope you guys could understand what I have written. Thank you in advance.. :)
You will not be able to preserve mouse movements once a MessageBox is created. This is a modal box that comes up on top of the existing window and takes the focus away from the current form and interrupts the mouse.
Consider an option that does not interrupt the mouse, such as writing out to a textbox. Create a TextBox will the multi-line and scrollbar options enabled. Then write to it.
private void usercontrolA_Leave(object sender, EventArgs e)
{
textBox1.Append("you are leaving A...\r\n");
}
private void usercontrolB_Enter(object sender, EventArgs e)
{
textBox1.Append("you are entering B...\r\n");
}
I'm currently just goofing around, programming an Web Browser.
i wonder how to Stop Navigation from WebView just with a button click?
if there's any bool/void's involved in the solution, explain it please.
Appreciate it!
If you are using WebView from WinRT, you can call WebView.Stop().
If you are using WebBrowser from WP Silverlight, you can subscribe Navigating event and set NavigatingEventArgs.Cancel as true.
Reference:
WebView.Stop Method
NavigatingEventArgs
You can do only using javascript,as below
private void Button_Click(object sender, RoutedEventArgs e)
{
Browser1.InvokeScript("eval", "document.execCommand('Stop');");
}
im learning wpf for the first time,
i have made this far
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
// TODO: Add event handler implementation here.
}
lets say its my click button 'home' some how i have made a new window store.xaml at the same product.
how can i connect them ?
heres a sc
Your question seems a bit vague to me, if you simply want to display the store inside the same window you should not implement the content of the window directly but only use the window as a shell for your content, if your store is a window as well you should refactor it into a UserControl which then can be added to the window.
You can also use Pages, see the Navigation Overview for more info on that.