|
i created a control which has a collection of an object which is not control.when i add an object to this collection during design time no code is added to my code page ,i want to know whether controls can be added from designer to a collection or i miss something..?
|
|
|
|
|
It is very difficult to determine what is your problem and what it is you are asking! But I will try to give you an answer.
If you have a control on a form that also has a collection of items (such as a ListBox) you can either add objects at design time or at development time. These, however, are not controls!
Controls (naturally) are added to forms at design time and you can add additional controls at runtime. You can also access the controls you added at design time.
Some controls (like infragistics) also have controls that have control collections. Again, you can add them at design time as well as at development time.
Access of the controls, what control to add, how to access and control them, is dependant solely upon the control itself.
There are 10 kinds of people in the world.
Those that read binary...
...and those who don't.
|
|
|
|
|
mmmmmm...
you know my control uses a colection objects that they are control,during design time i can add,remove and so on and i can see the effects but no extra code is written for them by designer and when i run my project its clear that i loose my collection .i want to know if i have to add some code to my control or collection to force the designer to apply codes to the project itself...
thanks...
|
|
|
|
|
Ah, now the clarity rises!
If you have it ATTRIBUTEd as a collection and it binds successfully with the CollectionEditor (the elipse opens the window to Add and Remove objects from the collection) then it should add the objects for you...in the designer.
However, you also will have to generate the required output so that the source code represents those objects. You should be creating the definitions for each individual object as well as the adding to the control collection in the InitializeComponent() section. So that is going to require hooking into the Changed event so that you can handle those changes in the source. This include removing any objects pulled out of the collection.
You will also probably have to do some reverse population, so that when the editor is closed/reopened you can gather your definitions/properties from the source code so that the designer properly represents the populated collection.
So you would have to generate:
...
MyNamespace.MyItemType {object namein collection};
...
private void InitializeComponents()
{
...
set any properties here that the user changed in the collection editor
MyNamspace.MyControl {theirname} = new MyNamspace.MyControl();
{theirname}.Items.Add({object namein collection});
Good Luck.
There are 10 kinds of people in the world.
Those that read binary...
...and those who don't.
|
|
|
|
|
you are right ...
although my collectioneditor works but it does not add any code ...
you say "you also will have to generate the required output so that the source code represents those objects" and my problem is here that when i'm using collectioneditor how i can generate the output?
thanks
|
|
|
|
|
There are one of two approaches you can take.
1- you need to know that an add/delete/change has occured within the collection. So you could write your own CollectionEditor which inherits from the ComponentModel.CollectionEditor (I think it is located there)
You need to check your methods available for override. I believe there is a method that the propertygrid calls into to validate a change. You need to intercept that call, identify the operation (add/change/del) then write out (or delete) the source code.
2- the other approach is to write your entire CollectionEditor yourself. Not a pretty sight.
Once you do that you need to overcome problem #2. How to gain access (addressability) to the current source document. I cannot help you there. You may have to do some searching on MSDN or try posting a question to GotDotNet and hope a developer sees your post.
I spent a year and a half in the bowls of PropertyGrid objects. Very complex stuff --- but boy do you get a hell of alot of power out of it. I am now known by my developers as the Voodoo Doctor because of the loosly bound objects that appear to easily flow together.
The problem you face is that the editors run in a vaccuum without too much knowledge of their environment unless it is available via Static methods. You may even have to delve into VSIP(?) which is the program/packages for accessing Visual Studio from Microsoft. I suspect you won't get far accessing a C# module without it!
There are 10 kinds of people in the world.
Those that read binary...
...and those who don't.
|
|
|
|
|
Build a quick app using the menu item. Add some menues to it and edit via property grid. Then look at your source and at your InitializeComponents() method. Make several changes and see how they propogate into the source. That is what you must accomplish.
There are 10 kinds of people in the world.
Those that read binary...
...and those who don't.
|
|
|
|
|
Hi ,
Thanks for your reply,my basic idea is calling everything from command prompt without showing windows or hiding windows,clearly what i want i have to pass username and password... from command prompt like this,
windowsApp1 -U userName -P password -S serverName -F fieldname(which is in database),after that every thing will have run as a background without showing windows.if possible send o/p to console.
i think its clear now,if you have any samples send me
thanks.
|
|
|
|
|
Why don't you just run it mininmized and set the form show in taskbar property to false. That makes it run invisibly.
|
|
|
|
|
Hi ,
Thanks for your reply,my basic idea is calling everything from command prompt without showing windows or hiding windows,clearly what i want i have to pass username and password... from command prompt like this,
windowsApp1 -U userName -P password -S serverName -F fieldname(which is in database),
after that every thing will have run as a background without showing windows
i thinkits clear now,if you have any samples send me
thanks.
|
|
|
|
|
Hi
Could anyone please explain to me why the following results in two mdi forms but the textbox only appearing on the second one? Clearly there is some sort of mechanism preventing me from hosting the same control on two different forms but I can't find any documentation regarding this.
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
this.IsMdiContainer = true;<br />
<br />
TextBox box = new TextBox();<br />
<br />
Form frmchild=new Form();<br />
frmchild.MdiParent=this;<br />
frmchild.Controls.Add(box);<br />
frmchild.Show();<br />
<br />
Form frmchild2=new Form();<br />
frmchild2.MdiParent=this;<br />
frmchild2.Controls.Add(box);<br />
frmchild2.Show();<br />
<br />
}<br />
Thanks in advance!
Ewan.
|
|
|
|
|
Try this:
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.IsMdiContainer = true;
TextBox boxA = new TextBox();<br />
TextBox boxB = new TextBox();
Form frmchild=new Form();
frmchild.MdiParent=this;
frmchild.Controls.Add(boxA);
frmchild.Show();
Form frmchild2=new Form();
frmchild2.MdiParent=this;
frmchild2.Controls.Add(boxB);
frmchild2.Show();
}
There are 10 kinds of people in the world.
Those that read binary...
...and those who don't.
|
|
|
|
|
No - i think you've missed the point of my original post. I know perfectly well I could do ask you suggest but that wasn't my question.
|
|
|
|
|
I answered your question with code. You need separate instances of the textbox -- one for each form. So yes, I answered your question.
There are 10 kinds of people in the world.
Those that read binary...
...and those who don't.
|
|
|
|
|
I think your trying to add the same instance of a TextBox control to two different forms at the same time?
This will not work because of threading, concurrency, message pump, and window handle issues. You MUST use two different instances of the control. Think about it. How is a dual-hosted, single instance control going to fire events in one window and not the other?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I want to read the properties of a MS Word file (like author, comments...) and I found two solutions:
- by starting a word application class
- by using the system32.dll
The problem with the first solution is that it uses a lot of ressources and takes quiet a bit of time (you actually open up the whole MS Word Software only to get some properties).
The problem with the second solution is that it doesnt work on Win2k or lower. It only works with WinXP or higher. The system32.dll of Win2k or below only gets the file size and creation dates and other properties but none of all those other MS Word specific properties.
So can anyone give me a hint how to get those properties on Win2k without opening a word application?
Thanks for any hints!
Bertram Weckmann
|
|
|
|
|
When is size assignment is done for the first time is done to a control?
|
|
|
|
|
at the form constructor in InitComponents() ,the windows designer handwork
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
Look in the "Windows Form Designer Generated Code" Region. You'll find all the properties, that are not default values, of your controls are set in there.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
From Life Cycle point of view when the page's Initialise id called it in turn calls the init of all controls on that page. At this point the control is initialised with all its properties. And finally after all the controls the Page initialise gets over.
Is this what u wanted.
Ketty
|
|
|
|
|
How can I print the content from a RichTextBox control?
the richTextBox.Document thing does not exist so how can I do it!
|
|
|
|
|
I think i already post answer for the same question.
Anyhow don't upset.;)
<br />
try<br />
{<br />
PrintDia=new PrintDialog();<br />
PrintDia.Document=printDocument1;<br />
string content=this.RitchEditor.Text;<br />
StrReader=new StringReader(content);<br />
if(PrintDia.ShowDialog()==DialogResult.OK)<br />
{<br />
this.printDocument1.Print();<br />
}<br />
}<br />
catch(Exception Ex)<br />
{<br />
MessageBox.Show(Ex.Message.ToString());<br />
}<br />
This much is very easy one who know how to print the content. Next is importent.
<br />
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)<br />
{<br />
try<br />
{<br />
float Lines_Per_Page = 0;<br />
float Y_Position = 0; <br />
int Count = 0;<br />
float Left_Margin = e.MarginBounds.Left;<br />
float Top_Margin = e.MarginBounds.Top;<br />
<br />
string Line = null;<br />
Font fnt = Editor.Font;<br />
SolidBrush Solid = new SolidBrush(Color.Black);<br />
<br />
Lines_Per_Page=e.MarginBounds.Height/Font.GetHeight(e.Graphics);<br />
<br />
while(Count < Lines_Per_Page && ((Line=StrReader.ReadLine())!=null ))<br />
<br />
{<br />
<br />
Y_Position =Top_Margin + (Count * fnt.GetHeight(e.Graphics));<br />
<br />
<br />
e.Graphics.DrawString(Line ,fnt ,Solid ,Left_Margin ,Y_Position ,new StringFormat());<br />
<br />
Count++;<br />
}<br />
<br />
if(Line !=null)<br />
e.HasMorePages=true;<br />
else<br />
e.HasMorePages=false;<br />
}<br />
catch(Exception Ex)<br />
{<br />
MessageBox.Show(Ex.Message.ToString());<br />
}<br />
<br />
<br />
}
Sreejith Nair
[ My Articles ]
|
|
|
|
|
|
Dear Mr. Gold !
I'm trying to find out about Face Recognition system using neural network (back propagation algorithm). I intent to write a program using C#.The most importance in face recognition is preprocessing step, i know that we can feed network with a pixel matrix of image but i don't know how to do this?? And would you mind give me some algorithm for image processing to improve its quanlity as reduce intensity, light, noise????
|
|
|
|
|
Hi
I am writing a windows forms app in C# and sometimes when i build and run the application in debug mode I get the two error screens with the following messages
An unhandled exception of type 'System.NullReferenceException' occured in Unknown Module
There is no source code available for the current location.
Does anyone have any ideas about this? There is no call stack to see where the issue is.
It does not occur every single time. Only about fifty percent of the time but it is anoying.
Thanks for any help.
|
|
|
|