Tuesday, 6 August 2013

Call function on another form .Net C#

Call function on another form .Net C#

I have a main form called "Principal":
public partial class Principal : Form
{
Then the user can click a button to open a second form as shown below:
private void opendicomdir_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "DICOMDIR|DICOMDIR";
ofd.FileName = string.Empty;
ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK)
{
if (ofd.FileName.Length > 0)
{
_reader = new DicomdirReader("DICOMDIR_READER");
_reader.Load(ofd.FileName);
directoriodelarchivo =
System.IO.Path.GetDirectoryName(ofd.FileName);
var form = new dicomdirselectionform(_reader); //second form
form.ShowDialog(); //Show second form
}
}
}
Then, on the second form, I load the DicomDir and I add a series of
buttons the user can click and when they do so, it calls a function in the
"Principal" form (the main form)
Here's the second form code, and down below the code for form.clickboton
public partial class dicomdirselectionform : Form
{
private void seriesclickbutton(object sender, EventArgs e)
{
Button botonseries = (Button)sender;
string id_serie = botonseries.Tag.ToString();
var form = new Principal();
form.clickboton(id_serie, _readern.Dicomdir);
this.Close();
}
}
Code for clickboton in the main form:
internal void clickboton(string id_serie, DicomDirectory dir)
{
//...
//I do some stuff here not related to my problem
// ...
MyProgress.Visible = true;
panel_info_imagen.Visible = true;
}
Here's my issue: in the clickboton function, when it's called from the 2nd
form, the objects (myprogressbar and the panel_info_imagen) won't show at
all! when I debug, the values are changed to "true" but never shown..
What may be the issue here?

No comments:

Post a Comment