First of all, I'm new to C# and also programming. So, my situation is after I insert data from a textbox to MySql database, the new data does not appear. FYI, I have the navigation (next previous) button. I have to re-run the apps in order for the new data to be displayed. Here's part of the codes:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//MySql codes to display in textbox
showData(pos);
}
public void showData(int index)
{
txtDisplay.Text = table.Rows[index][0].ToString();
}
private void btnPrevious_Click(object sender, EventArgs e)
{
}
private void btnNext_Click(object sender, EventArgs e)
{
}
private void btnGenNext_Click(object sender, EventArgs e)
{
//codes to generate new data and also insert into db
}
}
Here's my full codes:
Related
HI i wanted to Hide this error box:
i tried serching on internet but did not find usefull results , i am a fresher in coding so any way or any code that can help me ?
This issue is caused from server not acsepting first time but secind time it works great .
it would be great if u provide me easy steps .
MY Currrent code is
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Media_Player
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
label2.AutoSize = true;
label1.AutoSize = true;
}
private void button1_Click_1(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = ("http://y0b.net/radiosa.m3u");
MessageBox.Show("Successfuly Selected Radio SA , you will encounter a error , click close and then click play . " , "Thank You" , MessageBoxButtons.OK);
axWindowsMediaPlayer1.Ctlcontrols.play();
label2.Text = "Playing Radio SA";
}
private void button2_Click_1(object sender, EventArgs e)
{
axWindowsMediaPlayer1.Ctlcontrols.stop();
}
private void button3_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.Ctlcontrols.play();
}
private void button4_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = ("http://y0b.net/radiosa2.m3u");
MessageBox.Show("Successfuly Selected Radio SA Clasic , you will encounter a error after this mesage , click close and then click play . ", "Thank You", MessageBoxButtons.OK);
axWindowsMediaPlayer1.Ctlcontrols.play();
label2.Text = "Playing Radio SA CLASSIC ";
}
private void button5_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.Ctlcontrols.pause();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
axWindowsMediaPlayer1.Visible = false;
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
radioButton1.Checked = false;
axWindowsMediaPlayer1.Visible = true;
}
private void button6_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = ("http://y0b.net/radiosa3.m3u");
MessageBox.Show("Successfuly Selected Radio SA Dance Department , you will encounter a error after this mesage , click close and then click play . ", "Thank You", MessageBoxButtons.OK);
axWindowsMediaPlayer1.Ctlcontrols.play();
label2.Text = "Playing Radio SA Dance Department";
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
axWindowsMediaPlayer1.settings.volume = trackBar1.Value;
label4.Text = trackBar1.Value.ToString();
}
private void label4_Click(object sender, EventArgs e)
{
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
}
private void button7_Click(object sender, EventArgs e)
{
}
private void progressBar1_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.settings.playCount.ToString();
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
axWindowsMediaPlayer1.Ctlcontrols.pause();
}
}
}
Try this out. I suppressed the error message by setting enableErrorDialogs to false, then repeatedly asked it to play every 250 ms in a loop, with a ten second time out:
private async void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
axWindowsMediaPlayer1.settings.autoStart = true;
axWindowsMediaPlayer1.settings.enableErrorDialogs = false;
axWindowsMediaPlayer1.URL = "http://y0b.net/radiosa3.m3u";
DateTime stopAt = DateTime.Now.AddSeconds(10);
while (DateTime.Now<stopAt && axWindowsMediaPlayer1.playState!=WMPLib.WMPPlayState.wmppsPlaying)
{
axWindowsMediaPlayer1.Ctlcontrols.play();
await Task.Delay(250);
}
if (axWindowsMediaPlayer1.playState != WMPLib.WMPPlayState.wmppsPlaying)
{
MessageBox.Show("Failed to load stream!");
}
button1.Enabled = true;
}
Music started playing after about two seconds for me. Your mileage may vary...
Note that I added async to the method handler at the top to allow the use of await Task.Delay(250);.
I wonder how I could able to call MMap_MarkerClick from MMap_InfoWindowClick?
private void MMap_InfoWindowClick(object sender, GoogleMap.InfoWindowClickEventArgs e)
{
//call MMap_MarkerClick
}
private void MMap_MarkerClick(object sender, GoogleMap.MarkerClickEventArgs e)
{
ViewModel.MapMarkerSelected(e.Marker.Title);
}
I am trying to achive it, because MMap_InfoWindowClick does not open new ViewModel, but MMap_MarkerClick does. MarkerClick works but InfoWindowClick does not open ViewModel
How to press RoutedEventArgs e button (button in page) from EventArgs e button (button on application bar) in windows phone 7
private void button3_Click(object sender, EventArgs e)
{
button0_Click(sender, e);
}
private void button0_Click(object sender, RoutedEventArgs e)
{
}
when i am using above code its giving me
cannot convert from 'System.EventArgs' to 'System.Windows.RoutedEventArgs'
Please Help
SMS CODE:
SmsComposeTask SCT = new SmsComposeTask();
PhoneApplicationService PAS = PhoneApplicationService.Current;
public string SMSNO;
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
object sample;
if (PAS.State.TryGetValue("numbertext", out sample))
SMSNO = sample as string;
if (PAS.State.TryGetValue("messagetext", out sample))
txtOutput.Text = sample as string;
base.OnNavigatedTo(e);
}
private void button2_Click(object sender, RoutedEventArgs e)
{
if (txtOutput.Text != "")
{
SCT.To = SMSNO;
SCT.Body = txtOutput.Text;
SCT.Show();
}
else
{
MessageBox.Show("Output is Empty to send SMS.", "Wait!", MessageBoxButton.OK);
}
}
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
PAS.State["numbertext"] = SMSNO;
PAS.State["messagetext"] = txtOutput.Text;
base.OnNavigatedFrom(e);
}
If you don't use the parameter inside button0_Click, you can just call button0_Click(sender, null); (the reason is that the event from the application bar don't bubble that's why they don't have a RoutedEventArg parameter)
i need to take a picture from the directory of Windows phone in my application so i add a child Windows when i click on the text in this child Windows i add a button and i called
public partial class AnnotationControl : ChildWindow
{
public ObservableCollection<string> cercle { get; set; }
public AnnotationControl()
{
InitializeComponent();
}
private void ChildWindow_Closing_1(object sender, System.ComponentModel.CancelEventArgs e)
{
}
private void btnsave_Click_1(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
}
private void btnCancel_Click_1(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
}
private void browse_Click(object sender, RoutedEventArgs e)
{
PhotoChooserTask objPhotoChooser = new PhotoChooserTask();
objPhotoChooser.Completed += new EventHandler<PhotoResult>(PhotoChooseCall);
objPhotoChooser.Show();
}
but when i clicked on the button to choose a picture the application crashed
"Application_UnhandledException"
some one have any idea please
Use this may be helpful
private void changeImage(object sender, RoutedEventArgs e)
{
PhotoChooserTask photoChooserTask = new PhotoChooserTask();
photoChooserTask.Completed += new EventHandler<PhotoResult>(photoChooserTask_Completed);
photoChooserTask.Show();
}
void photoChooserTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
bmp.SetSource(e.ChosenPhoto);
imageTapped.Source = bmp;
}
}
I have a code that adds email id and name in Isolated space. But it is not able to add multiple data. Also, how can I update in case any data was entered incorrectly?
namespace IsoStore
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings;
}
private void button1_Click(object sender, RoutedEventArgs e)
{
IsolatedStorageSettings.ApplicationSettings.Add("email", "someone#somewhere.com");
IsolatedStorageSettings.ApplicationSettings.Add("name", "myname");
}
private void button2_Click(object sender, RoutedEventArgs e)
{
textBlock1.Text = (string)IsolatedStorageSettings.ApplicationSettings["email"];
textBlock2.Text = (string)IsolatedStorageSettings.ApplicationSettings["name"];
}
}
}
Cleaned up your code a little for you, using a helper method to do the store:
namespace IsoStore
{
public partial class MainPage : PhoneApplicationPage
{
private IsolatedStorageSettings _appSettings;
// Constructor
public MainPage()
{
InitializeComponent();
_appSettings = IsolatedStorageSettings.ApplicationSettings;
}
private void button1_Click(object sender, RoutedEventArgs e)
{
SaveSetting("email", "someone#somewhere.com");
SaveSetting("name", "myname");
}
private void button2_Click(object sender, RoutedEventArgs e)
{
textBlock1.Text = (string)_appSettings["email"];
textBlock2.Text = (string)_appSettings["name"];
}
private void SaveSetting( string setting, string value )
{
if (_appSettings.Contains(setting))
{
_appSettings[setting] = value;
}
else
{
_appSettings.Add(setting, value);
}
}
}
}
Try a few other examples to get your head around using IsolatedStorageSettings.
How to: Store and Retrieve Application Settings Using Isolated Storage
All about WP7 Isolated Storage - Store data in IsolatedStorageSettings
I have in mind 2 options, you either save your data to isolatedStorageFile MSDN Library OR ,this is what i might do in such case, You save under the key email all your emails as one string separate the emails with a char that is not allowed to be in an email, Coma "," lets say, when needed split your string and retrieve it to whatever makes you comfortable.
private void SaveSetting( string setting, string value )
{
if (_appSettings.Contains(setting))
{
_appSettings[settings] = _appSettings[settings] + "," + value;
}
else
{
_appSettings.Add(setting, value);
}
}
please note that this code segment is copied from HiTech Magic' answer.