I am working in an Excel file with Visual Studio and programming in C#. I added a listbox control to the sheet Seismic2D. I want to fill this listbox with information that is in the sheet FileList. The button that I am trying to program is in ribbon.
I tried to use Sis2D clase=new Sis2D(); but I got an error (There is no argument given that corresponds to the required formal parameter 'factory'of Sis2D.Sis2D(Factory,IServiceProvider)
In the Ribbon file...
public partial class Ribbon1
{
private void ListRefresh_Click(object sender, RibbonControlEventArgs e)
{
Excel.Worksheet wsFL = Globals.ThisWorkbook.Worksheets["FileList"];
Sis2D clase = new Sis2D();
clase.ListaFiles.Items.Add(wsFL.Range["A2"]);
clase.ListaFiles.Items.Add(wsFL.Range["A3"]);
}
}
In the Sis2D.cs file
public partial class Sis2D
Another thing that I tried was adding this in Sis2D
public partial class Sis2D
{
public void LlenaListBox()
{
Excel.Worksheet wsFL = Globals.ThisWorkbook.Worksheets["FileList"];
ListaFiles.Items.Add(wsFL.Range["A2"].Value);
ListaFiles.Items.Add(wsFL.Range["A3"].Value);
}
}
But I do not know how to call this method from the Ribbon partial class.
I want to be able to interact with the ListBox, adding items and reading them.
partial classis such a bad name. thepartialkeyword just indicates that your class definition may be spread across multiple files. Once compiled though, you got a single completeclass. --- so Dorian, look for the file that defined the constructor forSis2D.