|
This is my code
public Picturebox1()
{
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.Opaque, true);
this.BackColor = Color.Transparent;
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x20;
return cp;
}
}
And this was my error
Error 1 Method must have a return type C:\Users\Kyle\documents\visual studio 2010\Projects\PixModel\PixModel\Form1.cs 31 16 PixModel
Can anyone help I don't know what to do
|
|
|
|
|
I am guessing that line 31 is the definition
public Picturebox1()
And that PictureBox1 is not the name of your class. If it is, then which line is line 31? Double click the error message, and it will move to the line it is complaining about.
Only class constructors do not have a method return type. All others need at least void before the method name.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Yes that is where the error is
|
|
|
|
|
Then "PictureBox1" is not the name of your class - so that isn't the constructor - so it needs a return type, or you need to change the name to the name of your class (if this should be the class constructor)
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
How would I do the return thingy?
|
|
|
|
|
Either:
public int MyMethod(int myParam)
{
...
return myIntReturnValue
} (using whatever you want instead of int )
or
public void MyMethod(int myParam)
{
...
} But why are you calling it "PictureBox1" if it isn't a constructor? The name sounds like it should be a class derived from a PictureBox:
public class PictureBox1 : PictureBox
{
public PictureBox1()
{
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.Opaque, true);
this.BackColor = Color.Transparent;
}
} (allthough PictureBox1 is a silly name for a class, TransparentPictureBox would be better if that is what you are trying to achieve )
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Hi there,
I have a form containing two panels. In both panels there are two labels and textboxes. I set the 'Center In Form' property of the labels and textboxes to 'Horizontally' and 'Vertically' in design time respectively. But as the form is resizable, when the size of the form is increased or decreased at runtime the controls are no longer center aligned in the panels. How can I handle this problem (provided the main form needs to remain sizable)? Please help. Thanks.
|
|
|
|
|
Good god are people still trying to do this, this has been solved 1000s of times, look for some articles on resizing forms. There are multiple approaches to solving this and it really depends on what you want.
I tend to dock everything and leave the list control docked to fill, if there is no list control I don't bother just leave a blank area or put everything in a panel and anchor it to all sides.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Setting the Anchor property of the controls to none will solve it.
|
|
|
|
|
hi all
i derived a class from DataGridViewTextBoxColumn named DataGridViewTextBoxColumn2
public class DataGridViewTextBoxColumn2 : DataGridViewTextBoxColumn<br />
{<br />
[DefaultValue(typeof(bool), "true")]<br />
public bool IsMandatoryColumn<br />
{ get; set; }<br />
}<br />
in design time i click the Edit and change the value IsMandatoryColumn to true
but when i return to edit form to chock if the property set to true or not surprisingly i find this property with the value of False
please help me
by the way i tried to implement a constructor and set the default value there
and also tried to change the access method to old form of
<br />
get{return ...}<br />
set{...=value}<br />
but the problem still persists
pleeeeeeeeeeaaaaaaaaaaaaaaaaaase help me before i gonna crazy
|
|
|
|
|
hi
the answer is Pretty simple
public class DataGridViewTextBoxColumn2 : DataGridViewTextBoxColumn<br />
{<br />
[DefaultValue(typeof(bool), "false")]<br />
public bool IsMandatoryColumn<br />
{ get; set; }<br />
<br />
public override object Clone()<br />
{<br />
DataGridViewTextBoxColumn2 test = (DataGridViewTextBoxColumn2)base.Clone();<br />
test.IsMandatoryColumn = this.IsMandatoryColumn;<br />
return test;<br />
}<br />
}<br />
i love internet
|
|
|
|
|
The response you've got before is going to work, anyhow I think that you need to know why this won't work.
Thing is that DefaultValue, prevents the form's designer from generating code for this property. So when you set the property as true, no value is generated and bool variables always initialize to false.
That's what's giving you trouble.
|
|
|
|
|
hi dear gonzalo
NO
i used DefaultValue intentionally to prevent designer from generating this line of code
there is no different from having DefaultValue or not (i tried this senario several times) and it does not work.
i seams designer will clone the object and copy all the changed properties and i have to copy may new property implicitly.
|
|
|
|
|
Anyone has an example or resource on how to post to LinkedIn using C#?
|
|
|
|
|
Try this, looks like there is an API
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I'm experimenting with a Web Service, using .NET 2.0 and IIS7. This is the entire Web Service source (demo1.asmx):
<%@ WebService Language="C#" Class="Demo1ns.Demo1class" %>
using System;
using System.Web.Services;
namespace Demo1ns {
[WebService (Name="Demo1", Description="Test color result")]
public class Demo1class {
[WebMethod (Description="Get a size")]
public System.Drawing.Size GetSize() {
return new System.Drawing.Size(12,34);
}
[WebMethod (Description="Get a color")]
public System.Drawing.Color GetColor() {
return System.Drawing.Color.Yellow;
}
}
}
Browsing to http://localhost/services/Demo1.asmx I get the web page presenting both methods. Invoking the first works fine as it returns:
<Size>
<Width>12</Width>
<Height>34</Height>
</Size>
However the GetColor method (both variants) fails and simply returns:
<Color/>
whatever I try, a Color is never returned.
So why is it handling Size and not Color, both are pretty much similar structs. How does one fix this?
|
|
|
|
|
Ummm... because the XmlSerializer doesn't know how you want it serialized?
What would you like?
Have you tried -- "#" + System.Drawing.Color.Yellow.ToArgb().ToString ("X8")
or similar?
Or you could use -- System.Drawing.Color.Yellow.ToKnownColor()
|
|
|
|
|
I'm new to the whole Xml and WebService things. I managed to transfer lots of types including structs (such as Size) and DateTime, without worrying about formatting. In what I'm after Color is the only problem, I don't really care how it arrives at the client as all structs become class instances anyway on the client side (the Size struct becomes a Size-like class with a Width and a Height member), so if I want to use them as CLR types, I need to convert them anyway.
So please show me the simplest magic that gives me say the ARGB value, or something similar while keeping the server-side code simple (I don't want to add method calls everywhere (there are multiple color returns throughout the code, sometimes inside a result struct) if I can avoid it, otherwise I would have communicated the ToArgb() result.
TIA
|
|
|
|
|
You needs codez? Sounds Urgentz.
Just for the heck of it, I was just playing around with a Color wrapper class, with decent results.
[System.SerializableAttribute()]
public class Color : System.Xml.Serialization.IXmlSerializable
{
private static readonly System.Text.RegularExpressions.Regex reg ;
static Color
(
)
{
reg = new System.Text.RegularExpressions.Regex
(
@"^\#(?'Digits'[0-F]{8})$"
,
System.Text.RegularExpressions.RegexOptions.IgnoreCase
) ;
return ;
}
public System.Drawing.Color color { get ; set ; }
public System.Xml.Schema.XmlSchema
GetSchema
(
)
{
return ( null ) ;
}
public void
WriteXml
(
System.Xml.XmlWriter Writer
)
{
Writer.WriteString ( "#" + this.color.ToArgb().ToString ( "X8" ) ) ;
return ;
}
public void
ReadXml
(
System.Xml.XmlReader Reader
)
{
System.Text.RegularExpressions.MatchCollection mat =
reg.Matches ( Reader.ReadString() ) ;
if ( mat.Count == 1 )
{
int i ;
if
(
System.Int32.TryParse
(
mat [ 0 ].Groups [ "Digits" ].Value
,
System.Globalization.NumberStyles.HexNumber
,
null
,
out i
)
)
{
this.color = System.Drawing.Color.FromArgb ( i ) ;
}
}
return ;
}
}
I'm think of adding implicit conversions to it (and making the field private).
I probably won't be able to respond again until tomorrow afternoon (UTC -7:00).
|
|
|
|
|
wow. I was hoping for a magic attribute of some kind, and you offer 70+ lines of code. It will be a while before I have digested that.
Thanks.
|
|
|
|
|
What's a line?
Besides, maybe I'll need it someday.
If you like it, please send chocolate.
|
|
|
|
|
PIEBALDconsult wrote: What's a line?
When you have some amount of text, anything that sits between the beginning and the end gets chopped into smaller amounts (called "lines") either by newlines (you know them well) or by wrapping (you may be unfamiliar with that phenomenon).
PIEBALDconsult wrote: If you like it, please send chocolate
I would like it a lot if the deserializer method would get transferred automatically from server to client, just like the data members are when using WSDL.EXE to obtain the proxy class. Unfortunately only data members get through, as Keith stated.
PIEBALDconsult wrote: please send chocolate
I'll try some first, just to make sure.
Thanks again for your input.
|
|
|
|
|
The XML you transfer in web service calls are pretty much just bags of data that allow you to populate objects at either end. Unfortunately this is hidden from the outset in the .net framework tools. For example, you can create a "proper" object with methods, but these are lost on the client side if you just use the generated proxy classes the messages are deserialized into (at least not without extra developer jiggery-pokery).
Web services should theoretically be interoperable (e.g. a Java/ C++ clients should be able to call a .net web-service) if the Color object was directly serializable across the web service it would break this pattern as it is specific to .net. You have two [easy] ways to handle your problem: send the hex colour value as a string or (better) convert it to an integer. Obviously this will involve a little work to re-create the System.Color value.
|
|
|
|
|
Keith Barrow wrote: developer jiggery-pokery
One of my favorite things.
Edit:
Keith Barrow wrote: if you just use the generated proxy classes
So don't do that.
modified on Saturday, September 25, 2010 1:14 PM
|
|
|
|
|
Yes, in the mean time I discovered no methods make it across when using WSDL.EXE, all the client gets for free is a little class with data members (which is great by itself). As MSDN isn't very informative on jiggery-pokery (I myself am not familiar with such techniques) I'll probably go for the ToArgb() approach.
Many thanks for the information.
|
|
|
|