|
no
theres no need to share a form like that
Find a different design
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
Create a class library that contains the form and the code to display it then compile that into a DLL and call that from all your other apps.
My Blog[^] FFRF[^]
|
|
|
|
|
donkaiser wrote: can dll support graphical controls
Yes.
----------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
do you know any good examples on how to make a form into dll and how to call it?
Donkaiser
|
|
|
|
|
10 easy steps:
1) File->New->Project->Visual C#->Windows->Class Library
name it whatever you want (CP_DLLTest)
2) Project->Add New Item->Windows Form
Name it whatever you want (CP_DLLForm)
3) Build the DLL
4) File->New->Project->Visual C#->Windows->Windows Application
6) Project->Add Reference->Browse
Locate your DLL
7) place the correct namespace at the top of Form1.cs in the Windows Application
using CP_DLLTest;
8) Declare a class level object using the form name from the dll
private CP_DLLForm myTestForm = new CP_DLLForm();
9) Add a button to Form1 in your Windows Application
10) Show the class level form object
myTestForm.Show();
----------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
|
I'm looking for outlook navigator component, like one in Janus Controls, but, free
sample: http://www.componentsource.com/res/pub/img/products/full/513079.gif
|
|
|
|
|
1 - should control questions which apply to the .net framework go here (as I code in C#) or in the .NET Framework forum. I point blank refuse to post in both - I think that is not good practise.
2 - my real question. I've googled, msdn'd, and CP'd but I can't found out a) if you can disable the check boxes on a checklisbox and b) if you can, how?
Ideally I would like to disabled the whole item in the listbox, but disabling just the checkbox would suffice.
Regards
Angel
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
Hi Angel,
I would think that instead of having disabled items in the CheckedBoxList control, you would be better off removing those items that are undesirable/not valid, or more correctly, adding the list box items on the fly (filtering out the items that don't apply) with whatever changes would cause individual items to be come invalid.
Mike Poz
-- modified at 20:42 Thursday 15th June, 2006
|
|
|
|
|
Spooky - I went for that option and the client said 'no'. Their users need to know the option is there, and might become available soon, but isn't currently. The listbox shows servers with capacity below a certain threshold. When a threshold is reached, the server becomes 'unavailable' for that user, at which point I want the checkbox to be disabled. When a server is below capacity, a user can bag it by checking the listbox, which then 'disables' the server on other clients front end.
Looks like I will have to roll my own. Going for owner draw, dropping the list box and going for colours instead....Now, owner draw listboxes....hmmmm....back to google!
Thanks for your time anyway.
Regards
Angel
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
I have a control over another control. The top one is tranparent.
I need to grab the pixels below. Anyone have any hints on grabbing a pixel color on a specific point in a panel?
Thanks,
Nick
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
If you're using 2.0, the Control class has the DrawToBitmap method. You could draw the control to a Bitmap, and then use the Bitmap's GetPixel() method to retrieve the color at that point. I doubt this will be very performant, though!
josh
|
|
|
|
|
Yeah , but that only works for the current bitmap.
I really need to grab what the screen shows and draw that pixel.
I guess I will just use the API to get that data. I was hoping to avoid that.
thanks
1 line of code equals many bugs. So don't write any!!
|
|
|
|
|
I have a small form that I spawn from another that acts as a way to edit a row of data from a typed DataTable. Within the load() method of the form, I execute this code.
<br />
mySource = new BindingSource();<br />
<br />
mySource.DataSource = myManagerClient.VersionTable;<br />
<br />
uxcbFMonth.DataBindings.Add("SelectedValue", mySource, "FiscalMonth");<br />
uxtextFYear.DataBindings.Add("Text", mySource, "FiscalYear");<br />
uxtextName.DataBindings.Add("Text", mySource, "VersionName");<br />
uxcbType.DataBindings.Add("SelectedValue", mySource, "Type");<br />
That works just fine and the data is all bound correctly. The problem is that it defaults to the first row of data in the sorted bindingsource. I have a foreign key value for the datarow I want to display, and I know I need to use the BindingSource.Position property to properly set the position I want to edit, but I'm having problems correctly finding the value to pass.
I tried using mySource.IndexOf(/*The DataRow using myManagerClient.VersionTable.Select()*/), that returned -1.
I also tried to use mySource.Filter(), but that filters the data in the main form as well (since I'm using Form.Show() instead of Form.ShowDialog()), and visually, I think that will confuse the end-user.
As far as I can tell at the moment, I'm going to have to manually pass through each row until I find the right one, but there really seems like there might be an easy way that I'm just missing.
Any ideas?
|
|
|
|
|
Found it, I needed to change the second line above to include .Select().
|
|
|
|
|
I'll try to be as clear as humanly possible, forgive me if my termonology is off, here goes...
I created a class library.
The class library consists of 2 classes.
Class 1 -> A form.
Class 2 -> a "gateway" class allowing me to modify the form.
Class 2 has 2 methods.
Each method spawns a new instance of the form and sets a few form properties.
Fairly easy so far right?
Here's a concept method of class 2.
<br />
public void ShowA(string defaultValue)<br />
{<br />
MainForm form = new MainForm();<br />
<br />
form.DefaultValue = Convert.ToDouble(defaultValue);<br />
form.Title = "A";<br />
form.picWindow.Paint += new PaintEventHandler(form.PaintA);<br />
form.Show();<br />
<br />
WindowsAPI.ActivateWindow("Form1");<br />
}<br />
Basically when I call this method, the form's picture box draws a line at an angle I specified. Then I re-activate my non-class library form using API (I'm not sure how to communicate between class library classes and non-class library forms -- this isn't the problem though).
So yeah...
Back to what I originally mentioned, I only want 1 instance of each form open. A and B can be open, but 2x As cannot be open. I was able to do this with more API, pretty much checking for the hWnd of the window based on its title.
Now, here's the problem...
If the form is currently open, instead of doing nothing (I told it to not to call the class 2 method if it detects an open window already) I want it to UPDATE the value of the current open form (it would draw a new line and update the picture box).
How in the world can I do this?
|
|
|
|
|
Use the singleton pattern[^] to ensure that only one instance of your Form type(s) exist. (You'll need to check in the singleton accessor that the Form has not been closed, if so, recreate it, etc.) Define a method on your Form which performs the update, and have Class2 call into that when the update needs to occur.
HTH,
Josh
|
|
|
|
|
Ok, but if you read my message you'd see I don't want to limit the form itself to 1 instance.
The problem isn't related to limiting it to 1 instance.
As stated in my original post, the problem at hand is being able to update a class library form, from my main application, if an instance of it exists.
I'm not sure how to...
1) Setup Class 2 (read OP) to "trigger" an update.
2) Declare the class library form so I can use its properties/methods (I can't use 'new', etc.).
|
|
|
|
|
"I only want 1 instance of each form open. A and B can be open, but 2x As cannot be open."
Sounds like a good place to use the Singleton pattern.
|
|
|
|
|
I should have been more clear, sorry. A and B are the same physical form. The form consists of a picture box.
I had 2 functions, ShowA() and ShowB().
As a quick example, let's say...
when I call ShowA(), the picture box's paint event would draw 1 black line.
when I call ShowB(), the picture box's paint event would draw 1 red line.
Same form, different picturebox contents.
|
|
|
|
|
Here is a possible way to solve your problem.
If you only want one instance of each form open at once, then why do you create a new form each time one of the methods is called? Instead, declare each of the form variables inside your class as private and then when one of the methods is called you can simply create the form if it does not exist already, or if it does exist, then you can simply call a method on it to update its information.
Here is how you would write it:
private MainForm formA;
private MainForm formB;
...
public void ShowA(string defaultValue)
{
if(formA == null)
{
formA = new MainForm();
formA.DefaultValue = Convert.ToDouble(defaultValue);
formA.Title = "A";
formA.picWindow.Paint += new PaintEventHandler(formA.PaintA);
formA.Show();
}
else
{
formA.SomeUpdateFunctionWhichYouCreate(defaultValue);
}
} Make a method similar for formB. In this way, you won't be creating the form every time and you'll be able to tell the form to update itself via a function that you create on the form.
Hope that helps!
Sincerely,
Alexander Wiseman
|
|
|
|
|
Just read your other post in response to Josh. If you want to use the class without creating an instance of that class, then you need to make the variables and the functions which you wish to access static variables. My example will still work, just make the variables and the function static , like so:
private static MainForm formA;
private static MainForm formB;
...
public static void ShowA(string defaultValue)
... The thing to remember is that inside static methods, you can only access static variables of the class. This will not be a problem for you, however, since you want to use the class without creating instances of it, and therefore you will not have any instance variables.
Sincerely,
Alexander Wiseman
|
|
|
|
|
Fairly easy indeed. This eliminated the API calls required to check if the form exists (which was pretty sloppy I must say).
Everything works great now. I declared formA/B as private. Then created public methods CloseA/CloseB, which dispose/close the form and set the priv variable to null.
(The class is not static btw, I do initiate it in my main app)
Then created a method in the class library form which Invalides/Updates the picture box with the new value.
I can't believe I spent 5 hours googling/messing around on something that took 5 seconds to fix lol.
|
|
|
|
|
Glad that you got it working. I misunderstood your reply to Josh above, so I thought you needed static methods and variables. As long as you're creating instances of Class2, things are pretty straightforward
Sincerely,
Alexander Wiseman
|
|
|
|
|
Yep. I ran into a small road block, but I think I'll be able to fix it (in under 5 hours heh).
If I close the Class 1 form with the [X], I can't re-open it because the Class 2 private variables aren't set to null. Trying to figure it out, without having to set those variables as public.
|
|
|
|