Bunifu cannot access non-static property Visible - c#

I have been trying to make a menu which has 3 tabs. Login, News and website. I created user control and named it LoginTab.cs now I put the login panels in there LoginTab.cs, NewsTab. Now I am trying to make it visible and invisible depending on what tab people click. So if someone clicks news then the LoginTab goes away and shows the News tab. My problem is that I can't used LoginTab.Visible because its showing me "Cannot access non-static property 'Visible' in static context. How would I do this?
Main.cs
using System;
using System.Windows.Forms;
using UHWID;
namespace AnixLoader
{
public partial class Main : Form
{
bool username;
bool usergroup;
String SimpleUID = UHWIDEngine.SimpleUid;
String AdvancedUID = UHWIDEngine.AdvancedUid;
public Main()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Panel2_Paint(object sender, PaintEventArgs e)
{
}
private void Panel1_Paint(object sender, PaintEventArgs e)
{
}
private void Sdads_Click(object sender, EventArgs e)
{
}
private void PictureBox2_Click(object sender, EventArgs e)
{
}
private void CloseMenu_Click(object sender, EventArgs e)
{
Environment.Exit(0); // Closes Menu
}
private void BunifuFlatButton1_Click(object sender, EventArgs e)
{
LoginTab.Visible = true;
NewsTab.Visible = false;
}
private void News_Click(object sender, EventArgs e)
{
LoginTab.Visible = false;
NewsTab.Visible = true;
}
private void BtnMenu_Click(object sender, EventArgs e)
{
if (sidemenu.Width == 60)
{
//EXPAND
// 1. Expand the panel , w = 300
// 2. Show Logo
sidemenu.Visible = false;
sidemenu.Width = 300;
PanelAnimator.ShowSync(sidemenu);
LogoAnimator.ShowSync(Anix_Logo);
}
else
{
//MINIMIZE
//Using Bunifu Animator
// 1. Hide the logo
// 2. Slide the panel, w = 60
LogoAnimator.Hide(Anix_Logo);
sidemenu.Visible = false;
sidemenu.Width = 60;
PanelAnimator.ShowSync(sidemenu);
}
}
private void MainPanel_Paint(object sender, PaintEventArgs e)
{
}
}
}
LoginTab.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AnixLoader
{
public partial class LoginTab : UserControl
{
public LoginTab()
{
InitializeComponent();
}
private void LoginTab_Load(object sender, EventArgs e)
{
}
private void LoginText_Click(object sender, EventArgs e)
{
}
private void bunifuImageButton1_Click(object sender, EventArgs e)
{
}
private void Login_Click(object sender, EventArgs e)
{
}
private void Password_Click(object sender, EventArgs e)
{
}
}
}

I have resolved the problem by changing from this
private void BunifuFlatButton1_Click(object sender, EventArgs e)
{
LoginTab.Visible = true;
NewsTab.Visible = false;
}
private void News_Click(object sender, EventArgs e)
{
LoginTab.Visible = false;
NewsTab.Visible = true;
}
to this
private void BunifuFlatButton1_Click(object sender, EventArgs e)
{ // Log in button
this.MainPanel.Controls.Clear();
this.MainPanel.Controls.Add(new LoginTab());
}
private void News_Click(object sender, EventArgs e)
{ // News button
this.MainPanel.Controls.Clear();
this.MainPanel.Controls.Add(new NewsTab());
}

Related

How do I specify the location where my User Control shows?

I am extremely new to C# and any help would be appreciated. I am trying to create a simple multiple option menu with User Controls and I have got it in a semi functional state. I am trying to get the user controls to show in a certain location because as of now they are only showing from the top left down and that is not where I would like them. Any help would be appreciated. My Form1 code is below:
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 Menu_V2
{
public partial class Form1 : Form
{
StartScreen u1;
Softaim u2;
Triggerbot u3;
Macro u4;
Misc u5;
public static bool flag = true;
public Form1()
{
u1 = new StartScreen();
u2 = new Softaim();
u3 = new Triggerbot();
u4 = new Macro();
u5 = new Misc();
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void toolStripContainer1_ContentPanel_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void label5_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void label4_Click(object sender, EventArgs e)
{
u1.Hide();
u2.Hide();
u3.Hide();
u4.Hide();
u5.Show();
u5.Dock = DockStyle.Fill;
this.Controls.Add(u5);
}
private void insert(object sender, KeyEventArgs e)
{
}
private void bunifuThinButton21_Click(object sender, EventArgs e)
{
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F8)
{
}
}
private void button1_Click(object sender, EventArgs e)
{
}
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
}
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Insert)
{
this.Hide();
}
}
private void bunifuThinButton21_KeyUp(object sender, KeyEventArgs e)
{
}
private void bunifuThinButton22_Click(object sender, EventArgs e)
{
}
private void bunifuThinButton22_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F8)
{
this.Show();
}
}
private void misc1_Load(object sender, EventArgs e)
{
}
private void label6_Click(object sender, EventArgs e)
{
u1.Hide();
u2.Hide();
u3.Hide();
u4.Show();
u5.Hide();
u4.Dock = DockStyle.Fill;
this.Controls.Add(u4);
}
private void button1_Click_1(object sender, EventArgs e)
{
}
private void startScreen1_Load(object sender, EventArgs e)
{
}
private void label2_Click_1(object sender, EventArgs e)
{
u1.Hide();
u2.Show();
u3.Hide();
u4.Hide();
u5.Hide();
u2.Dock = DockStyle.Fill;
this.Controls.Add(u2);
}
private void label3_Click(object sender, EventArgs e)
{
u1.Hide();
u2.Hide();
u3.Show();
u4.Hide();
u5.Hide();
u3.Dock = DockStyle.Fill;
this.Controls.Add(u3);
}
}
}```

CS0501 error in Visual Studio 2017

So I have been coding C# for a few days, making a Roblox Exploit. I am making a drop down menu for my exploit, using timer ticks and it says "CS0501 C# must declare a body because it is not marked abstract, extern, or partial". I am a newbie at C# so I searched the problem up and I am not able to figure out why this problem is occurring. The code is down below. Please help, and if so, put down the code so I can just see what was my problem! Thanks!
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 WeAreDevs_API;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public void LuaTimer_Tick(EventArgs e, object sender);
private ExploitAPI wolfapi = new ExploitAPI();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
wolfapi.LaunchExploit();
}
private void buttonKill_Click(object sender, EventArgs e)
{
string target = usernameTarget.Text;
wolfapi.DoKill(target);
}
private void button1_Click_1(object sender, EventArgs e)
{
string target = usernameTarget.Text;
int speedValue = Int32.Parse(SpeedValue.Text);
wolfapi.SetWalkSpeed(target, speedValue);
}
private void button3_Click(object sender, EventArgs e)
{
string target = usernameTarget.Text;
wolfapi.TeleportMyCharacterTo(target);
}
private void speedValue_TextChanged(object sender, EventArgs e)
{
}
private void updateButton_Click(object sender, EventArgs e)
{
wolfapi.IsUpdated();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void button1_Click_2(object sender, EventArgs e)
{
string script = luaExecutor.Text;
wolfapi.SendLimitedLuaScript(script);
}
private void luaC_Click(object sender, EventArgs e)
{
string script = luaExecutor.Text;
wolfapi.SendScript(script);
}
private void noDoors_Click(object sender, EventArgs e)
{
}
private void luaExecutor_TextChanged(object sender, EventArgs e)
{
}
private void luaPanel_Paint(object sender, PaintEventArgs e)
{
}
private void luaOpen_Click(object sender, EventArgs e)
{
}
private void LuaTimer_Tick_1(object sender, EventArgs e)
{
}
}
}
Well,
public void LuaTimer_Tick(EventArgs e, object sender);
is a method without body, so you should either implement it:
public void LuaTimer_Tick(EventArgs e, object sender) {
//TODO: put relevant code here
}
or, technically, you can mark it as abstract (do not forget to mark class with abstract as well: public abstract partial class Form1 : Form {...})
public abstract void LuaTimer_Tick(EventArgs e, object sender);

How control opened tab in my web browser application?

Hi I'm new on C# and I made some simple Web Browser with tabs.
My problem is I don't know how to control selected tab. I mind if i click to back it go back on the selected tab.
Sorry for my bad English. This is my code:
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 HardRam
{
public partial class Form1 : Form
{
int i = 1;
public Form1()
{
InitializeComponent();
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
webBrowser1.GoBack();
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
webBrowser1.GoForward();
}
private void toolStripButton3_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("http://www.google.com");
}
private void toolStripButton4_Click(object sender, EventArgs e)
{
webBrowser1.Refresh();
}
private void toolStripButton5_Click(object sender, EventArgs e)
{
webBrowser1.Stop();
}
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate(textBox1.Text);
}
private void button3_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("http://www.google.com/search?&q=" + textBox2.Text);
}
private void label2_Click(object sender, EventArgs e) { }
private void toolStripLabel1_Click(object sender, EventArgs e) { }
private void toolStripButton7_Click(object sender, EventArgs e)
{
TabPage newTp = new TabPage();
WebBrowser newWB = new WebBrowser();
newWB.Name = "Page" + tabControl1.TabPages.Count + 1;
newWB.Dock = DockStyle.Fill;
newWB.Url = new Uri(#"http://www.google.com");
newTp.Controls.Add(newWB);
tabControl1.TabPages.Add(newTp);
}
private void toolStripButton8_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("http://www.google.com/search?&q=" + textBox2.Text );
}
}
}
You make an instance of web-browser for each tab,so you have to get current tab and its web-browser control , so in.see my following example:
private void btnaddtab_Click(object sender, EventArgs e)
{
TabPage newTp = new TabPage();
WebBrowser newWB = new WebBrowser();
newWB.Name = "Page" + tabControl1.TabPages.Count + 1;
newWB.Dock = DockStyle.Fill;
newWB.Url = new Uri(#"http://www.bing.com");
newTp.Controls.Add(newWB);
tabControl1.TabPages.Add(newTp);
}
private void btnback_Click(object sender, EventArgs e)
{
(tabControl1.TabPages[tabControl1.SelectedIndex].Controls[0] as WebBrowser).GoBack();
}
private void btnforward_Click(object sender, EventArgs e)
{
(tabControl1.TabPages[tabControl1.SelectedIndex].Controls[0] as WebBrowser).GoForward();
}

errorProvider1 does not contain definition and no extension method

I just started learning C# and started with Windows Forms project.
When I try to validate text fields I get this error:
Error 1 'Downloader.SDownloader' does not contain a definition for 'errorProvider1' and no extension method 'errorProvider1' accepting a first argument of type 'Downloader.SDownloader' could be found (are you missing a using directive or an assembly reference?) C:\Users\Bad_Wolf\documents\visual studio 2010\Projects\Register\Register\Form1.cs 77 22 Register
There is my source code:
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 Downloader {
public partial class SDownloader : Form {
public SDownloader() {
InitializeComponent();
}
private void fname_MouseClick(object sender, MouseEventArgs e) {
fname.Text = "";
}
private void fname_TextChanged(object sender, EventArgs e) {
}
private void lname_MouseClick(object sender, MouseEventArgs e) {
lname.Text = "";
}
private void lname_TextChanged(object sender, EventArgs e) {
}
private void username_MouseClick(object sender, MouseEventArgs e) {
username.Text = "";
}
private void email_MouseClick(object sender, MouseEventArgs e) {
email.Text = "";
}
private void password_MouseClick(object sender, MouseEventArgs e) {
password.Text = "";
}
private void password2_MouseClick(object sender, MouseEventArgs e) {
password2.Text = "";
}
private void password2_TextChanged(object sender, EventArgs e) {
}
private void register_Click(object sender, EventArgs e) {
}
private void fname_Validating(object sender, CancelEventArgs e) {
string errorMsg;
if (fname.Text.Trim().Length < 4) {
e.Cancel = true;
fname.Select(0, fname.Text.Length);
this.errorProvider1.SetError(fname, errorMsg);
}
}
private void fname_Validated(object sender, EventArgs e) {
}
}
}
The reason you are getting this error is because you haven't added the ErrorProvider to the form in the design view. Add the ErrorProvider and name it errorProvider1

Problem with appendText in c#

I have an app that has 3 text boxes, (users name, what company they are from, and who they are visiting) A button to print, and a keyboard on the screen (monitor is touch screen). I have everything working and functioning...
BUT, the one thing that does not work is when the user points to previous character in the text box that has already been typed, the buttons that "AppendText" (keyboard) do not start typing where the user pointed but it continues typing at the end of what has been typed.
Is this because of "AppendText" or some other issue that I have in my code?
I also am trying to get the first text box (Name_Box) to be sent to form one, which then will be split into two labels (1, first name| 2, last name) right now I have it being sent to one label But I want to split it so the first name is stacked above the second name in the next form (which is printed out).
Thank you so much.
Here is my code: First Form
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.IO;
namespace SMART
{
public partial class Form1 : Form
{
private TextBox tbSelected; // Last focused TextBox
private int posCaret; // Caret position
private int selLength; // Selection length
public Form1()
{
InitializeComponent();
// We will use leave event for textboxes
Name_Box.Leave += new System.EventHandler(textBox_Leave);
Company_Box.Leave += new System.EventHandler(textBox_Leave);
Visiting_Box.Leave += new System.EventHandler(textBox_Leave);
// Set initial selection to the first textbox
Name_Box.Select();
tbSelected = Name_Box;
posCaret = 0;
selLength = 0;
}
// Leave event handler
private void textBox_Leave(object sender, EventArgs e)
{
// Remember the last focused thextbox,
// the caret position in it and the selection length
tbSelected = (TextBox)sender;
posCaret = tbSelected.SelectionStart;
selLength = tbSelected.SelectionLength;
}
// Helper method to restore selection
private void RestoreLastSelection()
{
tbSelected.Select();
posCaret = tbSelected.SelectionStart;
selLength = tbSelected.SelectionLength;
}
private void Form1_Load(object sender, EventArgs e)
{
label5.Text = DateTime.Now.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
label5.Text = DateTime.Now.ToString();
Form2 frm = new Form2(Name_Box.Text);
frm.Show();
frm.Close();
StreamWriter sw;
sw = File.AppendText ("C:\\SignIn.txt");
sw.WriteLine ("Date and Time: " + label5.Text + " | Name: " + Name_Box.Text + " | Company: " + Company_Box.Text + " | Visiting: " + Visiting_Box.Text + " |");
sw.Close ();
Name_Box.Clear();
Company_Box.Clear();
Visiting_Box.Clear();
}
private void button42_Click(object sender, EventArgs e)
{
//SPACE BAR
tbSelected.AppendText(" ");
}
private void button24_Click(object sender, EventArgs e)
{
//DELETE
string t = tbSelected.Text;
if (t.Length > 0)
{
tbSelected.Text = t.Remove(t.Length - 1);
}
}
private void button12_Click(object sender, EventArgs e)
{
tbSelected.AppendText("-");
}
private void button13_Click(object sender, EventArgs e)
{
tbSelected.AppendText("Q");
}
private void button14_Click(object sender, EventArgs e)
{
tbSelected.AppendText("W");
}
private void button15_Click(object sender, EventArgs e)
{
tbSelected.AppendText("E");
}
private void button16_Click(object sender, EventArgs e)
{
tbSelected.AppendText("R");
}
private void button17_Click(object sender, EventArgs e)
{
tbSelected.AppendText("T");
}
private void button18_Click(object sender, EventArgs e)
{
tbSelected.AppendText("Y");
}
private void button19_Click(object sender, EventArgs e)
{
tbSelected.AppendText("U");
}
private void button20_Click(object sender, EventArgs e)
{
tbSelected.AppendText("I");
}
private void button21_Click(object sender, EventArgs e)
{
tbSelected.AppendText("O");
}
private void button22_Click(object sender, EventArgs e)
{
tbSelected.AppendText("P");
}
private void button25_Click(object sender, EventArgs e)
{
tbSelected.AppendText("A");
}
private void button26_Click(object sender, EventArgs e)
{
tbSelected.AppendText("S");
}
private void button27_Click(object sender, EventArgs e)
{
tbSelected.AppendText("D");
}
private void button28_Click(object sender, EventArgs e)
{
tbSelected.AppendText("F");
}
private void button29_Click(object sender, EventArgs e)
{
tbSelected.AppendText("G");
}
private void button30_Click(object sender, EventArgs e)
{
tbSelected.AppendText("H");
}
private void button31_Click(object sender, EventArgs e)
{
tbSelected.AppendText("J");
}
private void button32_Click(object sender, EventArgs e)
{
tbSelected.AppendText("K");
}
private void button33_Click(object sender, EventArgs e)
{
tbSelected.AppendText("L");
}
private void button35_Click(object sender, EventArgs e)
{
tbSelected.AppendText("Z");
}
private void button36_Click(object sender, EventArgs e)
{
tbSelected.AppendText("X");
}
private void button37_Click(object sender, EventArgs e)
{
tbSelected.AppendText("C");
}
private void button38_Click(object sender, EventArgs e)
{
tbSelected.AppendText("V");
}
private void button39_Click(object sender, EventArgs e)
{
tbSelected.AppendText("B");
}
private void button40_Click(object sender, EventArgs e)
{
tbSelected.AppendText("N");
}
private void button41_Click(object sender, EventArgs e)
{
tbSelected.AppendText("M");
}
private void button2_Click_1(object sender, EventArgs e)
{
tbSelected.AppendText("'");
}
private void button3_Click(object sender, EventArgs e)
{
tbSelected.Clear();
}
}
}
Heres is my code: Second Form
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;
using System.Drawing.Printing;
namespace SMART
{
public partial class Form2 : Form
{
public Form2(string strTextBox)
{
InitializeComponent();
label3.Text = strTextBox;
}
private void Form2_Load(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString();
PrintDocument pd = new PrintDocument();
Margins margins = new Margins(0, 0, 0, 0);
pd.DefaultPageSettings.Margins = margins;
pd.PrintPage += new PrintPageEventHandler(PrintImage);
pd.Print();
/*
//My sad attempt at splitting the Name
var fullname = strTextBox;
var names = fullname.Split (" ");
label3.Text = names[0];
label5.Text = names[1];
*/
}
void PrintImage(object o, PrintPageEventArgs e)
{
int x = SystemInformation.WorkingArea.X;
int y = SystemInformation.WorkingArea.Y;
int width = this.Width;
int height = this.Height;
Rectangle bounds = new Rectangle(x, y, width, height);
Bitmap img = new Bitmap(width, height);
this.DrawToBitmap(img, bounds);
Point p = new Point(0, 0);
e.Graphics.DrawImage(img, p);
}
}
}
You're right in that your problem is the use of AppendText, which always appends to the end (that's what append means).
You need to Insert the character at the current carat position.
You might do better to post a message that simulates a keypress from a physical keyboard.
If you want to insert text at the user's current position, you can use SelectedText. This will replace the current selection (if the user has selected characters):
tbSelected.SelectedText = "V";
Edit: The problem is in here:
private void button24_Click(object sender, EventArgs e)
{
//DELETE
string t = tbSelected.Text;
if (t.Length > 0)
{
tbSelected.Text = t.Remove(t.Length - 1);
}
}
You set the text, which returns the cursor to the beginning of the textbox. You should set tbSelected.SelectionStart after you clear the text.

Categories

Resources