|
Frnds,
i m working in C#.
My client wish to have a clored text in a texbox if my textboxes are disabled .
Can anybody suggest me any method to solve this problem of mine.
reply me via email.
Thanks
Sumit Kumar
sumit.professional@gmail.com
|
|
|
|
|
You need to enable the textbox to change the text, then disable it again. You can set the text color as a property on the textbox, I thought.
sumit_kumar wrote: reply me via email.
No. Set up your account to use your address, and you'll get no spam from CP, no spam because people won't be able to trawl the site and find your address, and an email when people answer.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian,
Good anwser, but I do have a side note though
The grayed out bit is a standard behaviour on a disabled textbox. This cannot be changed. However, there are some ways around it though.
1. Override the OnPaint event of the textbox.
{
SolidBrush drawBrush = new SolidBrush( ForeColor ); //Use the ForeColor property
// Draw string to screen.
e.Graphics.DrawString( Text, Font, drawBrush, 0f, 0f ); //Use the Font property
}
Note: You need to set the ControlStyles to "UserPaint" in the constructor.
public MyTextBox()
{
// This call is required by the Windows.Forms Form Designer.
SetStyle( ControlStyles.UserPaint, true );
InitializeComponent();
}
or something like that.
2. ( one of my favorites and less complicated ). Set the textbox to readonly and change te colors. This will preserve the textbox properties, allowing you to do anything with it that you want, and still mimic a 'disabled look'
private void OnClickButton(sender object, EventArgs e)
{
myTextbox.ReadOnly = true;
myTextbox.Forecolor = System.Drawing.Color.Red;
myTextbox.Backcolor = System.Drawing.Color.Gray;
}
Cheers,
|
|
|
|
|
I thought you could set the Text property even when the textbox was disabled?
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
I didn't think so. I have recollections of writing code to do what I suggested, out of necessity
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
We use
File.WriteAllBytes("//full path",byteArray)
to write file on the drive of the system we are working.
But if we want that instead of writing on the same system, it writes on other system on the LAN while we have the privileges to write it then what should be given as parameters in this method or is their any other class that support this?
|
|
|
|
|
Can you map a network drive to that directory and write it that way?
|
|
|
|
|
No .... without maping the network drive ....is it possible? if it is then how??
|
|
|
|
|
Well, you should be able to write to a UNC path, but it would have a lot to do with permissions. Your application may be running under a different identity or a lower trust level than is required. For instance, I can successfully run this code on my network:
static void Main(string[] args) {
FileInfo fi = new FileInfo(@"\\othermachine\C$\IAmATest.txt");
using (StreamWriter sw = new StreamWriter(fi.OpenWrite())) {
sw.WriteLine("Hello World!");
}
fi.Delete();
}
There's nothing special required to write to this particular path. I have this inside a command line app and I'm running on a domain account, so I know that I have access to write to that path. If you're running under an NT service or IIS, you may want to impersonate a different user account.
|
|
|
|
|
Hi All,
I want to add seperator on toolbar. I am using the following code to add button.
HelpButton = (CommandBarButton)oStandardBar.Controls.Add(1, missing, missing, missing, missing);
//firstButton.Style = MsoButtonStyle.msoButtonCaption;
HelpButton.TooltipText = "Help";
HelpButton.Tag = "btnHelp";
HelpButton.Click += new _CommandBarButtonEvents_ClickEventHandler(ButtonClick);
AddImage(ref HelpButton, "Help");
Please suggest how I can add seperator between two buttons on toolbar.
Thanks in advance.
asd
|
|
|
|
|
Hi,
Add a new button to your toolbar. Change its name to <anythingyoulike> , ( eg. tbbSeparator1 ) and change its Style to Separator.
When you change the Style property of the button to Separator, it disappears from the toolbar, or at least it seems to. When a button is designated as a separator, it's simply an empty placeholder used to create a space between two buttons. Because this separator is at the end row of buttons, you can't see it.
Move it to the second position by selecting it in the ToolBarButton Collection Editor and clicking the up arrow that appears to the right of the Members list; this arrow and the one below it are used to move a button up or down in the list. Click OK to save your changes and your toolbar will now have a space between the two buttons.
Have fun!
Regards,
|
|
|
|
|
Thanks for the reply.
But I am creating the add inn application and creating the command bar through the code (C#).
For button style i am using
customButton.Style = MsoButtonStyle.msoButtonIconAndCaption;
and no seperator kind of style available for MsoButtonStyle
Thanks.
asd
|
|
|
|
|
Use customButton.BeginGroup = true; for the second button.
|
|
|
|
|
An easy way of seeing how to do things like this is to create a dummy-project, set it up as you like to have it by using the graphical editor, and then look at the code.
Internet - the worlds biggest dictionary
|
|
|
|
|
I want to check a submenu, but i dont want this menu closes after that.
¿how can i do this?
nada
modified on Monday, September 12, 2011 11:58 AM
|
|
|
|
|
I think you have to be a bit more specific. What kind of submenu , how do you call it.
Cheers,
|
|
|
|
|
Hello,
I am having on delegate declared in a dll as
public delegate Object InvokeMethod(ResponseHandler responseHandler, Object[] arguments);
initialized in constructor
public ResponseProxy(InvokeMethod invokeMethod, ResponseHandler responseHandler)
{
responseHandler_ = responseHandler;
invokeMethod_ = invokeMethod;
}
Now i want to call ResponseProxy from my C# class and my problem is that how to pass first param "invokeMethod".
If i am calling it from Form class then i can do this.Invoke and working fine like
ResponseProxy(this.Invoke, EnumToolsHandler, "EnumToolsHandler")
but what if i am calling it from any .cs class. It requires InvokeMethod and if i create a object of it how should i initialize it
Please tell me how can i sort it out.
Thanks in advance.
Gajesh
Pune(India)
|
|
|
|
|
Hi all:
I have a form which more than one hundred TextBoxes on it,if one of the TextBoxes is changed(for instance,change the Text of the Box),how can I know that change?
Nothend
|
|
|
|
|
Hi
Just share the same event for all the 100 TextBoxes. For example if you know the Text changed TextBox Name,
private void textBox_TextChanged(object sender, EventArgs e)
{
TextBox txt = (TextBox)sender;
MessageBox.Show("The Current TextBox is " + txt.Name);
}
All the TextBox's TextChanged events will share the above event.
Cheers,
Chandru.
|
|
|
|
|
Thanks.
but I'm sorry, as you said ,I will write 100 enents of XXX_TextChanged ?
What I care is the change,if any of the TextBoxes is changed,I will set a boolean variable false.So how to achieve that?Thanks!
Nothend
|
|
|
|
|
Write one forAll_TextChanged and add it to all textboxes. Can be done "manually":
textBoXX.TextChanged += new System.EventHandler(forAll_TextChanged)
or by selecting it in the TextChanged-dropdown for each text box in event-tab in VS (2005 at least).
Note that you have to have the proper format of the forAll_TextChanged method.
Internet - the worlds biggest dictionary
|
|
|
|
|
Thanks a lot ,it works!!!
Nothend
|
|
|
|
|
use the TextChanged event of the textbox
|
|
|
|
|
Hi I’m working on a system that has 4 different types of client they have mostly the same attributes so I decided to create an interface IClient for them to implement and then just add the differing attributes as needed to each client class.
Now I get the Client information from a DB and Load them into a Generic dictionary
The class looks like so
[code]
class Class1<T> : Dictionary<int, T> where T:IClient
{
private IndemnityScheme scheme;
public Class1(IndemnityScheme scheme)
{
this.scheme = scheme;
}
public int Load()
{
// "procIndemnityClientSelect";
DataBaseAccess dba = new DataBaseAccess(this.scheme);
SqlDataReader reader = dba.LoadData("procPrsymClientSelect");
SmartDataReader smartReader = new SmartDataReader(reader);
while (smartReader.Read()) {
AceClient newClient = new AceClient(this.scheme);
newClient.Clientshort = smartReader.GetString("Client Short Name");
newClient.Clientname = smartReader.GetString("Client Name");
newClient.Clientref = smartReader.GetInt32("client ref");
newClient.AddressLine1 = smartReader.GetString("Address Line 1");
newClient.AddressLine2 = smartReader.GetString("Address Line 2");
newClient.AddressLine3 = smartReader.GetString("Address Line 3");
newClient.AddressLine4 = smartReader.GetString("Address Line 4");
newClient.AddressLine5 = smartReader.GetString("Address Line 5");
newClient.AddressLine6 = smartReader.GetString("Address Line 6");
newClient.Telephone = smartReader.GetString("Telephone No");
newClient.PostCode = smartReader.GetString("post code");
newClient.Contact = smartReader.GetString("Contact");
// newClient.Handler = smartReader.GetString("Handler");
newClient.Joindate = smartReader.GetString("Join Date");
newClient.Leavingdate = smartReader.GetString("leaving Date");
newClient.Salutation = smartReader.GetString("salutation");
newClient.Email = smartReader.GetString("Email");
newClient.Comments = smartReader.GetString("comments");
base.Add(newClient.Clientref, newClient);
}
smartReader.Close();
smartReader = null;
dba = null;
return base.Count;
}
}
[/code]
I call the class in my program like so
[code]
AceClient c = new AceClient(IndemnityScheme.ACE);
Class1<AceClient> cl = new Class1<AceClient>(IndemnityScheme.ACE);
cl.Load();
foreach (AceClient ac in cl.Values) {
System.Diagnostics.Debug.WriteLine(ac.Clientshort);
}
[/code]
Nothing fancy just want to loop throught the collection but on trying to complie I get an error.
This is the line of code that errors
[code]
base.Add(newClient.Clientref, newClient);
[/code]
Error 24 The best overloaded method match for 'System.Collections.Generic.Dictionary<int,T>.Add(int, T)' has some invalid arguments
Error 25 Argument '2': cannot convert from 'Prsym.AceClient' to 'T'
Can anyone tell me what I am doing wrong??
|
|
|
|
|
Does AceClient implement the IClient interface? This error can occur because the class violates the conditions of the generic (in this case where T implements IClient).
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|