I am developing this project "Profiling System" using MetroFramework and I've got this problem. If I click the next button I want my system to show the other panels where it has MetroTextboxes, MetroComboboxes, MetroCheckboxes and other tools of MetroFramework, But the panels does not appear.
I also want to try the UserControl just to slide it on the form but I don't know how. Please help.
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MetroFramework.Forms;
namespace TEST.cs
{
public partial class Form1 : MetroForm
{
List<Panel> listPanel = new List<Panel>();
int index;
public Form1()
{
InitializeComponent();
}
private void btnBack_Click(object sender, EventArgs e)
{
if (index > 0)
listPanel[--index].BringToFront();
}
private void btnNext_Click(object sender, EventArgs e)
{
if (index < listPanel.Count - 1)
listPanel[++index].BringToFront();
}
private void Form1_Load(object sender, EventArgs e)
{
listPanel.Add(metroPanel1);
listPanel.Add(metroPanel2);
listPanel.Add(metroPanel3);
listPanel[index].BringToFront();
}
}
}
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
so what i want is when you press the button you open form 2 where my game is. the button wich is at form 1 is going to be my main menu for the game, you click it and it opens the game and closes the menu (if it is possible to do this with out having 2 forms and just using 1 do share how i can do this)
Form 1
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 WindowsFormsApplication3
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
Form 2
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 Spill
{
public partial class MainWindow : Form
{
Random _random;
public MainWindow()
{
InitializeComponent();
_random = new Random();
}
private void MainWindow_Load(object sender, EventArgs e)
{
Size s = new System.Drawing.Size(800, 600);
this.ClientSize = s;
this.FormBorderStyle = FormBorderStyle.FixedSingle;
}
private void MainWindow_KeyDown(object sender, KeyEventArgs e)
{
{
if (e.KeyCode == Keys.Left)
{
Player.Left -= 20;
}
if (e.KeyCode == Keys.Right)
{
Player.Left += 20;
}
}
}
private void timer1_Tick(object sender, EventArgs e)
{
int z = _random.Next(0, 10);
int x = _random.Next(0, 20);
int y = _random.Next(0, 30);
LargeEnemy.Left += z;
MediumEnemy.Left += x;
SmallEnemy.Left += y;
}
private void newGameToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Restart();
}
private void quitGameToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void LargeEnemy_Click(object sender, EventArgs e)
{
}
}
}
It's very simple:
using System;
using System.Collections.Generic;
using System.ComponentModel;
System.Data;
System.Drawing;
using System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//hide the current winform
this.Hide();
//create game winform
WindowsFormsApplication1 frmGame = new WindowsFormsApplication1();
//show the game winform
frmGame.ShowDialog();
//when the game winform closes show again the menu
this.Show();
}
}
}
and in the second form in this functions set them like this
private void newGameToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void quitGameToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
This is a very simple example using a form manager to handle a single instance. This way both forms stay live and you are just updating the visibility.
You will want to close both forms correctly to close the application.
namespace WindowsFormsApplication1
{
static class FormManager
{
public static Form1 Game = new Form1();
public static Form2 Menu = new Form2();
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(FormManager.Game);
}
public partial class Form1 : Form
{
private void btn_Menu_Click(object sender, EventArgs e)
{
FormManager.Game.Hide();
FormManager.Menu.Show();
}
}
public partial class Form2 : Form
{
private void btn_Close_Click(object sender, EventArgs e)
{
FormManager.Menu.Hide();
FormManager.Game.Show();
}
}
}
i am new to .net i am having trouble playing videos automatically. I would be showing different textboxes here but i want the video to autplay without any buttons
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;
using WMPLib;
namespace ThinkQDisplay
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
AxWindowsMediaPlayer1.URL = "C:\Users\Ramrod\Documents\Visual Studio 2012\Projects\ThinkQDisplay\ThinkQDisplay\sample.avi";
}
}
}
It keeps telling it is an unrecognized escape sequence. Also I would like to have a separate form (form2). Where I can choose what to play here on form 1. Is it also possible to have it looped?
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = #"C:\Users\Ramrod\Documents\Visual Studio 2012\Projects\ThinkQDisplay\ThinkQDisplay\sampler.avi";
}
private void Form1_Load(object sender, EventArgs e)
{
axWindowsMediaPlayer1.settings.autoStart = true;
}
}
}
I am in need of a bit of help searched around the internet for about 2 days
to try and figure out how i can call an AxShockwaveFlash Variable from a second form this is for a game trainer something simple just getting into C# so i thought id start with one of these however i love everything i make to have a nice look and as many options as i can add so for my first C# Trainer i added a MenuStrip that opens a second form(VariableMods.cs) it has a few radio buttons a text box 3 toggle switches and 2 buttons one for setting a variable to whatever is typed in the text box while checking which radio button is checked and a button to close the variable menu which is another thing i need a bit of help with
-How do i Close the Second Form but still keep my Toggles On?
-How do i Call A Variable From (Form1.cs) to Form2(VariableMods.cs)
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 OCULAS
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Show the Variable ModMenu
private void openVariableModsToolStripMenuItem_Click(object sender, EventArgs e)
{
VariableMods VarMenu = new VariableMods(this);
VarMenu.Show();
}
//Show About Program Box
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
InfoBox1 AboutBoxx = new InfoBox1();
AboutBoxx.Show();
}
//Close the Program
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
That is my Form1 Code Have Not Put anything into it about the ShockwaveFlash yet
And
here is Form2(VariableMods)
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 OCULAS
{
public partial class VariableMods : Form
{
Form1 originalForm; //Using "OriginalForm" To Call "Form1"
public VariableMods(Form1 IncomingForm)
{
originalForm = IncomingForm; //originalForm(Form1) is the form to be called
InitializeComponent();
BoxHeadVariables utf = new BoxHeadVariables();
}
private void ambiance_Button_21_Click(object sender, EventArgs e)
{
this.Hide();
}
private void ambiance_Button_11_Click(Form1 incomingForm, object sender, EventArgs e)
{
if (ambiance_RadioButton1.Checked == true)
{
MessageBox.Show("Damage Mod Is Active");
}
if (ambiance_RadioButton2.Checked == true)
{
MessageBox.Show("Speed Mod Is Active");
}
if (ambiance_RadioButton3.Checked == true)
{
MessageBox.Show("Range Mod Is Active");
}
}
}
}
I am trying to make a multiform application that takes a DataGridView of table attributes and shows them in a DetailView upon the click of a button. When I click the button and the second form opens it is empty. Then if I close the second form I get 'An unhandled exception of type 'System.NullReferenceException' occurred'. Here is my code:
Form 1
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 MultiForm
{
public partial class Form1 : Form2
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'personnelDataSet.employee' table. You can move, or remove it, as needed.
this.employeeTableAdapter.Fill(this.personnelDataSet.employee);
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnDetails_Click(object sender, EventArgs e)
{
Form2 dForm = new Form2();
dForm.ShowDialog();
this.tableAdapterManager.UpdateAll(this.personnelDataSet);
}
}
}
Form 2
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 MultiForm
{
public partial class Form2 : Form
{
//public Form2()
//{
// InitializeComponent();
//}
private void employeeBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.employeeBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.personnelDataSet);
}
private void Form2_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'personnelDataSet.employee' table. You can move, or remove it, as needed.
this.employeeTableAdapter.Fill(this.personnelDataSet.employee);
}
}
}
I get the exception on form 1 at this.tableAdapterManager.UpdateAll(this.personnelDataSet); Any help would be greatly appreciated.
Didn't drag in the data components into the tray duh... Sorry guys.
I'm trying to make a multiWindowsForm.
Just to try how it is working I started with a a simple form that I added a button to. When clicking on it, another window should pop up. But I can't get it to work. It crashes with error:
Object reference not set to an instance of an object!
I used Project → Add → Windows form and named it Mupp.cs
Here's my code for Form1.cs :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MultiForm
{
public partial class tryout : Form
{
public tryout()
{
InitializeComponent();
}
Mupp theMupp;
private void Form1_Load(object sender, EventArgs e)
{
theMupp = new Mupp();
}
private void button1_Click(object sender, EventArgs e)
{
theMupp.Show();
}
}
}
What can I have missed out on?
It looks like the load event is not firing and thus not initilising your object. Make sure that the load event is hooked up.
Alternatively, initialise in the click event.
private void button1_Click(object sender, EventArgs e)
{
using (Mupp theMupp = new Mupp())
{
theMupp.ShowDialog();
}
}
I hope this helps.
public tryout()
{
InitializeComponent();
this.Load += new EventHandler(Form1_Load);
}