Hey all,
I'm trying to get started with .net. I've worked through the DevTV labs and got a bunch of great info, now I'm trying to make some magic happen, and I'm running into a bit of trouble.
Through the DevTV labs, you create a userControl, and make a command which uses the usercontrol as a class to create a paletteSet, and display it. The palette that you create has a treeView on it which gets populated with entity info, and later you create a drag-and-drop event from a label on the palette.
This looked like a pretty good starting point for something I'd like to do. I want to make a paletteSet of some common commands for my users. I have plans of having controls related to those commands next to buttons which will launch the commands. For now, I've added some buttons to my userForm, which I want to trigger commands.
Code:
...using...
namespace FTools
{
public class AutoCADTools
{
public PaletteSet myPaletteSet;
public FTools.FToolsPalette myPalette;
[CommandMethod("FTools")]
public void showFToolsPalette()
{
if (myPaletteSet == null)
{
myPaletteSet = new PaletteSet("FTools", new System.Guid("FDA43192-4967-453B-8EB4-6D9CDEFA2A33"));
myPalette = new FTools.FToolsPalette();
myPaletteSet.Add("FTools", myPalette);
}
myPaletteSet.Visible = true;
}
public void myFirstFunction()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("I would now run myFirstFunction");
}
public void mySecondFunction()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("I would now run mySecondFunction");
}
}
}
This compiles, and when I netLoad and run FTOOLS, my paletteSet is displayed, and I love it.
So here's the code of the FToolsPalette class:
Code:
...using...
namespace FTools
{
public partial class FToolsPalette : UserControl
{
public FToolsPalette()
{
InitializeComponent();
}
private void FirstFunctionButton_Click(object sender, EventArgs e)
{
myFirstFunction();
}
}
}
And the line " myFirstFunction() " is highlighted with the message "The name 'myFirstFunction' does not exist in the current context"
I think this has to do with the fact that the FToolsPalette exists in the context of the window(?) and the function would need to be run in the context of the editor(?) but I'm new here and I'm not sure if that is correct.
Does the function which a button calls need to be in the same class as the button? How does this allow me to organize my code into separate classes?
How far off the mark am I?
Thanks!
EDIT:
I also put a comboBox onto the palette in visual studio. How do I access this comboBox?
I thought that after creating a new FToolsPalette called myPalette, I could do myPalette.comboBox1, but myPalette doesn't intellisense anything after it...