|
You are really getting what you want here. What you need to do is ponder the error message for just a minute. Once you get used to *thinking* (relatively hard I suppose) about what messages express, you can interpret them relatively easily. Get used to thinking hard if you want to write software. You are going to have to develop cleaner thinking habits than "normal" people.
("Dirty thinking people,' in C# nomenclature.)
The message tells you what your declaration is, and it is trying to tell you (no more cryptically than practical) how your declaration errs.
You have declared "Exer10Ch4.SchoolFigures.DetermineName(string)"
The term "body" must refer to a pair of braces {}. I had to figure that out myself as well (as I haven't got such an error in a long long while).
So, what the error is saying that if your declaration doesn't have a body, it must refer to an external declaration somewhere, for which case you have to declare it with the extern keyword:
extern Exer10Ch4.SchoolFigures.DetermineName(string);
This probably isn't the error (but possibly it is).
The compiler is telling you that it would also accept this statement if it were marked as abstract:
abstract Exer10Ch4.SchoolFigures.DetermineName(string);
The other condition it is telling you it would accept is that you declare a body:
Exer10Ch4.SchoolFigures.DetermineName(string)
{
}
The compiler is trying (all it can, really) to help you be a clean thinking person. You need to pay attention to the rules of the core language to interpret the message (easily, and cleanly).
|
|
|
|
|
Hello Friends,
I have implemented client server application.
I send data like user name, status etc.
e.g.- "User#ONLINE:Tester".
But Problem is that when i send data simultaneously.
Firsly, i send "User#OFFLINE:Tester" and a small interval and then "User#ONLINE:Tester"
but i get data like,
firstly,
"User#OFFLINE:Tester"
and next time new data get appended to this only.
"User#OFFLINE:TesterUser#ONLINE:Tester"
Is there any flush mechanism or any solution to sort this problem.
Rahul Kulkarni
|
|
|
|
|
hi all
i am working in a parent child relationship.
i am trying to close the parent form when the child form closes, but its not working.
how do i do this??
Saira
|
|
|
|
|
i think you are talking about mdi child and parent, then in child closing event you can call this.mdiparent.dispose(); to close both forms.
Regards
Shajeel
|
|
|
|
|
this code closes the mdi parent and child , but it doesn't call the closing function of the child form(which i am using).
now how do i get over this problem??
|
|
|
|
|
you should be calling this function after doing every thing you want to do in closing event like
private void Form2_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //all your code this.MdiParent.Dispose(); }
Regards
Shajeel
|
|
|
|
|
:->
thanks dude
Regards
Saira
|
|
|
|
|
Here's the trilemma that I'm in: I want to XML serialize an object tree. Some properties have getters only, so there are a few options to serialize those (note that this is in a web service scenario, so the schemas are required too):
- Go the easy way, add setters to the properties. This degrades the class design somewhat, but might be acceptable.
- Go the hard way, implement IXmlSerializable and hand code the serialization (note that the schema must be created too, using the XmlSchemaProviderAttribute). This option doesn't degrade the class design, but at a considerable cost. I have explored some in this direction, using the XmlReflectionImporter class some short cuts might be taken in creating the schema, but I haven't successfully combined this technique with a hand written implementation of XmlSchemaProviderAttribute (see here[^] for more details for those interested).
- Try something really groovy, uncharted territory, and thus potentially more risky. I was thinking about writing a reflection based serializer/deserializer/schema creator myself. How hard can it be? It's just a bunch of properties, and collections. I'd add the ability to serialize a property with only a getter. That's the only issue with the default xml serializers. Basically the behaviour would be the same as serializing collections, those can have a getter only too.
So, which option would be the wisest? Am I overlooking any options that I don't know of or didn't think of?
Wout
|
|
|
|
|
Hi!
Could any one suggest me how I can display tooltips for a disabled controls! It was fairly easy to implement the same in MFC but em not able to find a solution in C#
Thanks in advance!
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
place another control behind the disabled control so that only when your control is disabled then mouse events go to that control, in that control's mouse move event call tooltip.settooltip for the control that is behind.
Regards
Shajeel
|
|
|
|
|
Thanks!
But my application is having too many controls, and having duplicate control underneath each really blots it up
- Nilesh
|
|
|
|
|
Hi
You can add hidden control (HTML or asp:hiddenfield) as this will not disturb your UI.
Harini
|
|
|
|
|
i think a better solution will to created user controls for all controls you use, but it will be time consuming and you will have to replace all your control in your application with custom controls.
Regards
Shajeel
|
|
|
|
|
but again custom controls would also face the same problem! won't they?
|
|
|
|
|
Yes, it should be (considered) forbidden to frivolously use resources.
Documentation tells us that tootips are never displayed for disabled controls. That means the behavior is not supported by the tooltip class. You would have to write your own tooltip-like class to detect mouse-over and so forth if you wanted to override this behavior, but that would be a steep price to pay to provide a tooltip for something that isn't functional at the moment in the first place.
|
|
|
|
|
Was wondering if there was any workaround,
similar problem is seen with MFC controls as well but there you have the pretranslatemessage which allows you to handle it by sending explict messages to tooltip controler.
Is it possible to implement something similar here too
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
I really can't tell you that, but it's a good question, particularly as the disabled state itself could be an obstruction. I mean of course, that whenever someone discovers such a workaround, there's a good chance they walked down a few difficult dead ends (as successfully as possible) to find it -- so it's a good idea to ask in case someone might have the pattern handy. If so, it might be a long shot that such a person might see your post.
Still, I think I'd lean away from this. Your post in fact first gave me the idea I might try a workaround to provide an additional capacity in a control I'm working on, but then I thought no, it's not often (if ever possibly) very logical to provide tooltips to disabled controls... so (for me at least, as far as I can see), I decided to accept the default functionality, particularly considering how much effort and resource overhead might be wasted to deliver the behavior you are asking for.
That said, if you want pointed in the initial directions that strike me, what you might try that might not increase resource reliance too disproportionately, is detecting the parent of your control and setting the region of your control on the parent to take a mouse hit test, sampling the mouse state to raise your own hint possibly from the parent. That even may be too wild an idea or technically challenging a project.
|
|
|
|
|
Thanks for the pointer,
I too was thinking on the same line. To capture region of disabled object and set required tooltip for parent, let me give a shot at it.
Thanks again!
Nilesh
|
|
|
|
|
Well, good luck on that.
Just one other thing. If your control is composite/aggregate of course, you should be able to pull this off without too much difficulty. Otherwise, it certainly would be a boon to be able to have an inside look at the ToolTip class. Some people say some of that kind of source can be found. If you can dig it up, the behavior you want may be no more difficult than overriding a method, possibly only to eliminate the logic fork that refrains from tooltip display when controls are disabled.
Personally, I think Microsoft would benefit the development community tremendously by exposing selected source (like this) to us. Instead of our present far-reaching discussion without much tangible to present to each other, dozens of people could recommend just how to override whatever method. That's how it was in Delphi and C++Builder a few years back, before Borland management made the mistake of letting .Net blow them out of the water.
|
|
|
|
|
Can you give me any detail or any url where I can find about how to create chm files programmatically using C#??
Thanks in Advance
Praveen
|
|
|
|
|
|
Good day,
I have a form, i've set the BackColor to Black and also the transparency to Black.
then on the form a UserControl which has a gradient backcolor.
Inside the UserControl i've put two basic controls(Label1 and Button1).
I've set the BackColor of Label1 and Button1 to Transparent. What happened is
that the Label1 and Button1 transparency goes through the form itself. See Link Below:
http://www.geocities.com/fritzjeran/Sample.JPG
What I really wanted is that when i set the BackColor of the Label1 and Button1
to transparent, I goes through ONLY up to the UserControl (i.e what should appear
is the gradient color of usercontrol on the area that is overlapped by label1 and Button1).
How should I fix this?
Here is the code of my Usercontrol:
public partial class BaseControl : UserControl
{
public BaseControl()
{
InitializeComponent();
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.EnableNotifyMessage, true);
}
protected override void OnPaint(PaintEventArgs e)
{
if (this.BackgroundImage == null)
{
Rectangle rect = new Rectangle(0, 0, Width, Height);
LinearGradientBrush b = new LinearGradientBrush(rect, Color.White, Color.Blue, 90);
GraphicsPath path = GraphicsPathUtility.GetRoundRectPath(rect, 10);
e.Graphics.FillPath(b, path);
}
base.OnPaint(e);
}
}
#region Utility Classes
public class GraphicsPathUtility
{
private GraphicsPathUtility()
{
}
public static GraphicsPath GetRoundRectPath(RectangleF rect, float radius)
{
return GetRoundRectPath(rect.X, rect.Y, rect.Width, rect.Height, radius);
}
public static GraphicsPath GetRoundRectPath(float X, float Y, float width, float height, float radius)
{
GraphicsPath gp = new GraphicsPath();
gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);
gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);
gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));
gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);
gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);
gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);
gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);
gp.CloseFigure();
return gp;
}
}
#endregion
I would like also to acknowledge those who previosly help me. Thanks.
|
|
|
|
|
I have a simple question. I would like to be able to test data conversions from string to other data types without throwing exceptions if it fails (throwing exceptions seems a bit sloppy). Here is a sample of what currently works, but I would like a cleaner version.
public bool IsInt(string sData)
{
bool bRtn = false;
try
{
int iTmp = Convert.ToInt32(sData);
bRtn = true;
}
catch (Exception) { }
return bRtn;
}
Any better ideas I'd love to hear them. This works but it will throw exceptions if the string cannot be converted to the correct data type (here int).
Thanks for your input.
Leo T. Smith
|
|
|
|
|
TryParse, types like bool, int and double expose a TryParse method which returns false if they fail
string s ="NotABool";
bool b;
if (!bool.TryParse(s, out b))
{
// not a bool.
}
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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, I'll try this in the morning.
Leo
Leo T. Smith
|
|
|
|
|