I have two forms: one has a listbox with a list<>. I need to access the selected item of this textbox on a second form.
First form(GestaoJogadores_Admin):
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 WindowsFormsApplication1
{
public partial class GestaoJogadores_Admin : Form
{
private DiagramaEntidadesContainer dbATMT;
public GestaoJogadores_Admin()
{
InitializeComponent();
dbATMT = new DiagramaEntidadesContainer();
RefreshListaJogadores();
}
private void button_editarGestaoJogadores_Click(object sender, EventArgs e)
{
EditarJogador_Admin EditarJogadorAdmin = new EditarJogador_Admin();
Player jogadorSelecionado = (Player)lb_Jogadores.SelectedItem;
DialogResult resultado = EditarJogadorAdmin.ShowDialog();
}
}
}
Second form(EditarJogador_Admin)
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 WindowsFormsApplication1
{
public partial class EditarJogador_Admin: Form
{
private DiagramaEntidadesContainer dbATMT;
public EditarJogador_Admin()
{
InitializeComponent();
dbATMT = new DiagramaEntidadesContainer();
}
private void button_EditarJogadorOk_Click_1(object sender, EventArgs e)
{
GestaoJogadores_Admin GestaoJogadoresAdmin = new GestaoJogadores_Admin();
Player jogadorSelecionado = (Player)GestaoJogadoresAdmin.jogadorSelecionado;//this is what I need, but it doenst work. I get an errror: 'GestaoJogadores_Admin' does not contain a definition for 'jogadorSelecionado' and no extension method 'jogadorSelecionado' accepting a first argument of type 'GestaoJogadores_Admin' could be found (are you missing a using directive or an assembly reference?)`
}
}
}
I open my second form creating an instance of it on the first one and using ShowDialog. On the second on, I thought that if I did the same and tried to access the "jogadorSelecionado" inside of it, It would work, but It doesnt...
In your first form on the button change
Player jogadorSelecionado = (Player)lb_Jogadores.SelectedItem;
try
EditarJogadorAdmin.passFromFormOne = (Player)lb_Jogadores.SelectedItem;
And on your second form add the variable to pass it too.
public Player passFromFormOne;
then
Player jogadorSelecionado = passFromFormOne;
Related
I am new to C# and can't get OpenSlide to work. I need it to be able to read SVS files. Below is the code I have used. Is it possible I am missing something in a directory? My boss has used the same code and can get it to run without issue.
I am getting the following error:
OpenSlideNET.OpenSlideUnsupportedFormatException: 'Exception of type 'OpenSlideNET.OpenSlideUnsupportedFormatException' was thrown.'
using OpenSlideNET;
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 SVSCurrent1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OpenSlideImage image = OpenSlideImage.Open("C:\\projects\\SVS\\JP2K-33003-1.svs");
}
}
}
Below is my code extract relative to the problem
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Timers;
using System.Threading.Tasks;
using System.Web.UI.Design;
using System.Windows;
using System.Windows.Forms;
using cef;
using CefSharp;
using CefSharp.WinForms;
public partial class Form1 : Form
{
//browser variables
public ChromiumWebBrowser chrome;
public Form1()
{
InitializeComponent(); InitBrowser(); this.WindowState =System.Windows.Forms.FormWindowState.Maximized;
}
public void InitBrowser()
{
chromeheight = this.Height-100;
chromewidth = this.Width;
Cef.Initialize(new CefSettings()); chrome = new ChromiumWebBrowser("correct url here");
this.Controls.Add(chrome); chrome.Anchor = AnchorStyles.Left;
chrome.Size = new Size(chromewidth, chromeheight);
chrome.Location = new Point(0, 100);
chrome.LoadingStateChanged += chrome_LoadingStateChanged;
}
public void chrome_LoadingStateChanged(object sender,LoadingStateChangedEventArgs e)
{
//the problem!!!
chrome....
}
}
the problem is at the last line. When I type chrome.IsLoaded, the IsLoaded option is not available. Everything else works fine.
below is the error I get.
Error 17 'CefSharp.WinForms.ChromiumWebBrowser' does not contain a
definition for 'IsLoaded' method 'IsLoaded' accepting a first argument of
type 'CefSharp.WinForms.ChromiumWebBrowser' could be found (are you missing
a using directive or an assembly reference?)
What am I doing wrong?
I am new to C# and have been trying for hours to accomplish this simple task of reading a file into an array and displaying in a listbox. However, it never seems to read the file and the listbox is blank and I don't get any errors. What am I missing?
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 System.IO;
namespace WorldSersisChamps
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string[] lines = System.IO.File.ReadAllLines(#"C:\Users\jsommer\Documents\Classes\WorldSersisChamps\WorldSersisChamps\bin\Debug\Sales.txt");
foreach (string line in lines)
{
lbTeams.Items.AddRange(lines);
}
}
}
}
Here is my code: I am trying to find the roblox PlayerBeta but its not working
I am not the best in coding but I found out how to find it but cant implent it right into the code
( EDIT ) The program works if I use the PID but that changes everytime I open up a new RobloxPlayerBeta ! so I cannot use that
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 Memory;
using System.Diagnostics;
namespace ForceField
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Mem MemLib = new Mem();
private void button1_Click(object sender, EventArgs e)
{
if (System.Diagnostics.Process.GetProcesses().Any((p) => p.ProcessName.Contains("RobloxPlayerBeta")))
{
int robloxPid = System.Diagnostics.Process.GetProcessesByName("RobloxPlayerBeta").FirstOrDefault().Id;
}
Console.WriteLine(robloxPid);
MemLib.writeMemory("0x184C3A98", "string", "PlsNoBan ");
Console.WriteLine(MemLib.readString("0x184C3A98"));
}
}
}
Omg I am stupid.. xD
I needed to do MemLib.OpenGameProcess(robloxPid)
I tried dragging a data source object from my Patients table into the form by expanding patients, going to appointments (it is there because it is connected with a foreign key) and dragging the appointment time onto the form.
When I run the program, I get "Cannot bind to the property or column Ap_time on the DataSource."
I am at a loss and am stressing out over this.
Heres my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Validation;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class PatientMaster : Form
{
public PatientMaster()
{
InitializeComponent();
}
ClassLibrary3.HospitalEntities dbcontext = new ClassLibrary3.HospitalEntities();
private void PatientMaster_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
dbcontext.Patients.OrderBy(patient => patient.Pat_Last_Name).ThenBy(patient => patient.Pat_First_Name).Load();
patientBindingSource.DataSource = dbcontext.Patients.Local;
}
}
}
I think you are missing ToBindingList():
patientBindingSource.DataSource = dbcontext.Patients.Local.ToBindingList();