|
plz tell me how to do it? (Any guidelines of code)
Thanks for your reply
|
|
|
|
|
The other class must know about the form - so you must pass details of the form to the other class (remember, forms are classes too) somehow. Then the class can access the form. You must provide a mechanism on the form to receive the request
class MyForm : Form
{
...
public void DisableControls()
{
}
}
class MyOtherClass
{
private MyForm myForm;
public MyOtherClass(MyForm myForm)
{
this.myForm = myForm;
}
public SomeMethodThatNeedsToDisableTheControls()
{
...
myForm.DisableControls();
...
}
}
Does this help?
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
If you hold a reference to the form, you can manipulate everything on it that is
declared public, as in myForm.myButton.Enabled=true;
But it is considered bad design to make controls public, since everyone holding
the reference (myForm) can also replace, resize, move, hide, ... said control.
In fact, it is almost always wrong to provide public fields, only methods and
properties should be candidates for the public attribute.
An acceptable approach is:
- keep the controls private (or protected) to your form class;
- provide public methods (or properties) inside your form class, that offer
the required functionality to the outside world, no more, no less;
- pass the form's reference to your class and have it use the public methods
or properties.
And if you are familiar with delegates, they offer the best approach. It basically
means your form creates a delegate (that's like a function pointer connected
to the form's object), so now it can pass that delegate to your class, without
even having to pass the form's reference itself. That is encapsulation, provide
as little as possible, just give what is absolutely necessary.
|
|
|
|
|
Hi .
Yes you can , something like following code :
<br />
public class ControlForm<br />
{<br />
public static void EnableTextBox()<br />
{<br />
FrmTest frmTest = new frmTest();<br />
frmTest.txtName.Enable = true;<br />
}<br />
}<br />
Important :Set your control modifier property to Internal or Public
Bad Programming :Don't try to do this . It's not a smart coding .
DMASTER
|
|
|
|
|
Even you can use Delegates for Enabling/Disabling controls of the Form. The Delegate will remove the requirement to declare control objects (Text etc) public.
Manoj
Never Gives up
|
|
|
|
|
Manoj Kumar Rai wrote: The Delegate will remove the requirement to declare control objects (Text etc) public.
Text is a parameter on the control. You cannot make that public. You must make the control public, or create a new property on the form that proxies for the control's property.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Yes Yes, You are corrrect. I meant TextBox there.
Manoj
Never Gives up
|
|
|
|
|
Thank you very much.
Ramu
|
|
|
|
|
I'm already say it .
So , what ...
DMASTER
|
|
|
|
|
I want to genrate a log of event in text box?
How can i do that?
Actually i am regularly looking up an event and when event is being raised then its appropriate message is get printed in text box.
But it get printed on same text(of event), means previous text erased and new text(of event) get printed?
I want every event text appears like log,
I tried Environment.NewLine but no use?
How to acheive this.
Plz help
|
|
|
|
|
humdumof wrote: I tried Environment.NewLine but no use?
How did you try ?
tb.Text = tb.Text + Environment.NewLine + log;
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
thanks?
Actually i m coding like
tb.Text = event + Environment.NewLine;
not adding previous text?
After writing like this problem solved.
tb.Text = tb.Text + event + Environment.NewLine;
Thanks for helping.
|
|
|
|
|
Hi All
After trying to do a system restore I noticed that I was not able to load or execute my C# project. It seems Window removed the .sln file. Is there a way I could recreate it and revive my project?
|
|
|
|
|
Open the csproj.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Sadly, that file is gone as well. I don't understand why it was deleted in the first place. The .resx file is missing as well so even though the form1.designer.cs file is there I can't open the design layout. All I have are the .cs C# program files. I guss I would need to recreate the csproj file as well as the resx file. Can that be done as well?
|
|
|
|
|
|
Hi everybody,
for ticker(scrolling text from left to right or from top to bottom rotated) I have used html file with java script. and am showing this in a browser control in my C# application. This script uses cookies, hence it uses around 30% CPU utilization, which is very high.
Please suggest something, which will take low CPU utilization.
Thanks
and best regards
Rabindra Patra
|
|
|
|
|
Well, pretty much any other way would be better. I'm sure there are controls on this site, or just write one, derived from the label control.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks for the reply.
Actually, I need some more features. For the time being I have done the thing. But how can I give Fade in effect, or some other effects?
I thing using Direct X it can be done, But I am not getting how to do it.
|
|
|
|
|
can anyone explain what is the difference b/w machine.config and web.config
pavan...
|
|
|
|
|
Apparently[^], many can, and have.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Web.config
This file contains settings specific to an application. It contains configuration settings that the common language runtime reads (such as assembly binding policy, remoting objects, and so on), and settings that the application can read.
Machine.config
This file contains settings that apply to an entire computer. This file is located in the %runtime install path%\Config directory. Machine.config contains configuration settings for machine-wide assembly binding, built-in remoting channels, and ASP.NET.
For more details pls have a look at MSDN
Manoj
Never Gives up
|
|
|
|
|
Can any one help me with this.I am trying to copy a string which has length greater than 255 characters in to a ExcelTextBOx.But it not working if i send 255 characters it working fine.
my code is like this
string temp;
Microsoft.Office.Interop.Excel.TextBox txtbox1=(Microsoft.Office.Interop.Excel.TextBox)workbook.TextBoxes("TxtboxName");
txtbox1.text=temp;
txtboxname is the name of the textbox on excel
I have one more question string in temp is from a Label on my webpage.It Has some text bolded .How to preserve the format on ExcelTextBox .
Please somebody help me with these i am trying for answers since so long.
Thanks
KU
|
|
|
|
|
Hi,
I would like to access several webservices I created.
Should these be called directly from the win/web forms
OR
should the win/web forms call the classes inside the Business Layer (BL) and let the BL call the webservices?
Thanks
|
|
|
|
|
Ok, I got this project where it consist of building webcontrols based on XML values. I'm not even sure if this is possible, but it must.
For example if an XML key value = "System.Web.UI.WebControls.BoundColumn" it obviously means a bound column. With that key value string, how do I tell the framework to create that?
First time having to do this, so I'm laying out psudeo:
-if string key = "System.Web.UI.WebControls.BoundColumn" then convert Webcontrol to BoundColumn
If anyone got ideas on how to do this please share. A generic code would also be helpful. I've to explore converting objects to specific "objects" if that makes any sense.
Thanks all in advance!!!
|
|
|
|