This is my class code
public Label Createlabel()
{
Label intervillabel = new Label();
intervillabel.Text = numericUpDown1.Value.ToString();
intervillabel.Location = new Point(BeatDetector.Location.X, 0);
intervillabel.AutoSize = true;
intervillabel.Visible = true;
return intervillabel;
}
say this is my other code, this will add the label to the panel
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.ControlKey)
{
panel1.Controls.Add(Createlabel());
}
}
this is the the hard part of the code
beatdetector = picurebox
string detectstring = "";
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
private void BeatDetector_Move(object sender, EventArgs e)
{
if (BeatDetector.Location.X == Createlabel().Location.X)
{
if (Createlabel().Location == new Point (0,Createlabel().Location.Y))
{
detectstring = Createlabel().Text;
string Str = detectstring.Trim();
double Num;
bool isNum = double.TryParse(Str, out Num);
if (isNum)
{
MessageBox.Show(Num.ToString());
}
else
{
MessageBox.Show("Invalid number");
if (Createlabel().Text == "KICK2")
{
SoundPlayer player = new SoundPlayer(Properties.Resources.KICK2);
player.Play();
}
}
}
}
}
whats ment to happen is when the picure goes over the label it will see if the label is a text or a number, if it is a number it will convert it int to a number and a message bot will show up saying its conveted into a number and I can use the coverted number for anything, but for some reason nothing happens.
PS: I have a draggable beatdetecor that I drag around the panel