|
Import a colour?
I'm not sure what you mean, but there's a couple of ways you can get a colour:
1: By Name
Color myColour = Color.DarkGreen;
2: Specify the RGB values
Color myColour = Color.FromRGB(50, 255, 200);
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
|
Though not stripes, I threw this example together. You can paint anything in OnPaintBackground.
<br />
Color m_Color1 = Color.Red, m_Color2 = Color.Black;<br />
<br />
public Color Color1<br />
{<br />
get { return m_Color1; }<br />
set { m_Color1 = value; }<br />
}<br />
<br />
public Color Color2<br />
{<br />
get { return m_Color2; }<br />
set { m_Color2 = value; }<br />
}<br />
<br />
protected override void OnPaintBackground(PaintEventArgs e)<br />
{<br />
Brush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Point(e.ClipRectangle.Left, e.ClipRectangle.Top), new Point(e.ClipRectangle.Right, e.ClipRectangle.Bottom), m_Color1, m_Color2);<br />
e.Graphics.FillRectangle(brush, e.ClipRectangle);<br />
}<br />
|
|
|
|
|
Nice and Cool
THNKS
Have Fun
Never forget it
|
|
|
|
|
it is un believiable:
but the TabPage control do not have the :
Enabled, Visiable - Properties????
what in |The world gone wrong????
but The most ridiculous thing is that microsoft say u have them
But they Addes : "This member is not meaningful for this control."
Why???
So my problem is this :
i like to disable a tab when it is not meaningful without the selected index Property
Any Ideas????
Have Fun
Never forget it
|
|
|
|
|
Well, you could remove the tab page when its useless, and add it back again when it becomes usefull. I'm pretty sure each tab page is a whole separate object.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
|
The tabPage exists within the form and removing it from the tabControl means that it is not shown. You want to be careful not to re-add the tabPage control or to remove it if its not there.
|
|
|
|
|
Yah, i know
But i decided to just disable all of the objects inside of the TabPage
THANKS anyway
Have Fun
Never forget it
|
|
|
|
|
once my boss told my to disable a tabpage...
when told him that is not possible he laughed at me
and told me do some reading
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
|
You're right, but there is a very easy workaround for this problem.
1. Create a new tab control that is hidden on your form.
2. When you want a tab page to go away, Set the .Parent property of your tab page = to the hidden Tab Control object.
3. When you want the tab page back, Set the .Parent property of your tab page = to the visible Tab Control Object.
Enjoy!
Hogan
|
|
|
|
|
THANKS
i'll try it
Have Fun
Never forget it
|
|
|
|
|
I have situation in code where I have to deal with the File Creation Time.
I have used System.IO.File class to check for the existence of the File and then deleted it, then in another function created the File using FileStream Class with FileMode.Create and CreateNew Parameter.
File is delete in both cases from disk, (as it shows in the folder - with FileInfo and System.IO.File) but when the File is created again with FileMode.Create and FileMode.CreateNew, it has the older creation date i.e. the date of the deleted file.
Can anyone help on this with a thorough and solid answer?
Muhammad Talha
|
|
|
|
|
Well, it seems strange that it would keep the old date/time but i'm sure there's a reason.
Until you find out why, you can set the creation time yourself. Sadly, i can't remember where exactly you do that, you may need to do a bit of googling.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
|
Hi all,
In my .NET 1.1 Windows application I am using the validating event to check the correct field contents of a TextBox. When the contents was wrong I used e.cancel=true; and set the Focus on the TextBox again. I am leaving the TextBox by a button click event.
I would expect that the validating event comes before a button click event occurs, but that's wrong. The button click will not be canceled.
What must be done to cancel the button click when the e.cancel event of the TextBox becomes true ?
Or can I check in my button click function if a cancel has happend anywhere ?
Thanks in advance
Frank
|
|
|
|
|
The event order is Validating, Validated and lost focus.
So before you click on the button, the text box events are fired.
You must use the validating event of the text box and use a flag on behalf of that to execute the button click.
Muhammad Talha
|
|
|
|
|
Just tried this and it works okay, add a textbox and button to a form:
<br />
private void textBox1_Validating(object sender, CancelEventArgs e)<br />
{<br />
if (string.Compare(textBox1.Text, "foo") != 0)<br />
{<br />
e.Cancel = true;<br />
}<br />
<br />
}<br />
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
MessageBox.Show("bar!");<br />
}<br />
If text box hasn't got foo then there is no bar.
Doesn't matter if you tab or click away, the focus stays with the unvalidated control.
Hope this helps,
|
|
|
|
|
Thank you for your answer,
this is what I would appreciate to have.
But in my Application the MessageBox was shown !!!
This is what i don't understand.
the Button is on a Tab of the tabcontrol and the TextBox is on a panel of the same tab, don't know if this metters ?
An idea ?
Thanks
frank
|
|
|
|
|
I can only think that your event is not bound to the text control. If the validating event is cancelled then the focus will stay on the text control.
In the textbox's properties check the events and at the bottom look at Validating it should be (in the example) textBbox1_Validating
|
|
|
|
|
Hi all
In my C# class I have my simple field declared as
String MyField{
get{
return MyString;
}
}
If I use for it the delegate declared as
delegate String StringDelegate();
List< StringDelegate > a = new List< StringDelegate >(100);
List.Add( MyField );
It doesn'! work. It tells me that it cannot convert
annot convert from 'string' to 'StringDelegate'
How I can refer to my field function using delegate?
Kind Regards
ManuStone
|
|
|
|
|
Before I get to your real question, we need to make sure we are on the same page. In your code example above, MyField is a property, not a field. Below is an example of a field and a property:
private String myField = String.Empty;
public String MyProperty {
get {
return this.myField;
}
}
Now, for your question. There is no direct way to create a delegate to a property's get or set accessors. It is possible, as shown here[^], but it's somewhat of a hack. I call it a hack, because you need to pass the name of the property to get the delegate. So if you change the name of the property, then your delegate will be broken.
You may be able to use anonymous methods[^] (see Figure 10) to accomplish what you want.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
You are right! Sorry for having being not very detailed (always too hurry while work!
Many Thanks for your time and for the articles you suggested.
Manu
|
|
|
|
|
As stated in the C# Programming Guide at MSDN delegates can only be used with named or anonymous methods.
AFAIK there is no way to define a delegate for a property ("field function").
If you change your Property to something like:
String GetMyField()
{
return MyString;
}
it should work.
Cheers
Markus
|
|
|
|