|
In one form i added graphics using paint in the picture box, how can i get the same graphics in another form's picture box,at the same time graphics should run in both the forms using c#
modified on Tuesday, April 21, 2009 8:26 AM
|
|
|
|
|
Derive a class from Picture box and override the OnPaint handler. You can then just treat your new class as a control and drop it on whatever forms you want.
Regards,
Rob Philpott.
|
|
|
|
|
Hi,
I need to insert an instance of user defined class into a datarow in datatable.
I tried casting to the class name,object everything, but its always showing as string object. Anybody having any idea about this... A sample code is given below....
dataRow[dataColumn] = (MyClass)value;
Here value is an object of type MyClass...bt after execution, the result in dataRow[dataColumn] is of type string object..
Please help...its urgent...
|
|
|
|
|
How do you want your object to be inserted in the row?
|
|
|
|
|
Just want to insert it as class object...
foreach(MyClass obj in MyClassCollection)
{
dataRow[dataColumn] = obj;
}
Just this, nothing more... bt dis is showing as "MyClass" of type object{string}
|
|
|
|
|
what is the type of dataColumn?
|
|
|
|
|
I am not sure, but I think that it is using the ToString() method. As it is managing to store the class, I can only assume that the datacolumn type is one of the text variants (varchar, nvarchar etc.).
I think that you are going to have to use blob storage techniques, together with (possibly binary) serialization, to do this.
Maybe you will get lucky and someone who has done something like this will help.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
well i cant image you are wanting to display the class in any way in a cell so why dont you try using the Tag property of the DataRow? I am assuming you just need to get information from the class why you have a row selected.
dataRow.Tag = myClass;
then when you need it you can just do...
MyClass myClass = (MyClass)dataRow.Tag;
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
1. How do you know the value is a string?
2. The property indexer of DataRow is typed to return object, but you can cast it back to the original type.
|
|
|
|
|
hi,
I making a windows application in C# and my problem is that,
I have a square picture. I need to draw a circle on it, and everything
outside that circle to be set to a certain color, so the image looks framed
On other words, I want to crop a circle form a rectangular picture
Any hints/any help ..........
thanks in advance
|
|
|
|
|
Hi,
the Graphics class holds all you need: methods FromImage() and DrawEllipse() should do it.
You may use several DrawEllipse() with increasing radius to remove the four corners, or just one
with appropriate radius and Pen width.
|
|
|
|
|
thanks for give me such idea....
can you tell me how to fill color on the remaining portion of the image when we make a circle on it.
thanks.........
|
|
|
|
|
Make the Ellipse bigger than the picture and use a huge pen width.
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
|
|
|
|
|
hi friends I am new to .NET,
I have the following code to save an image file in specific location.
It does compile and it is showing that null reference eexception is unhandled
it is asking to create an object instance in this line (System.Drawing.Imaging.ImageFormat)
how can it be done any help please
SaveFileDialog save = new SaveFileDialog();
save.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
save.Title = "Save the File";
save.ShowDialog();
string fName = save.FileName;
if (save.FileName != "")
{
System.IO.Stream fileStream = (System.IO.FileStream)save.OpenFile();
switch (save.FilterIndex)
{
case 1:
this.button7.Image.Save(fileStream, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
case 2:
this.button7.Image.Save(fileStream, System.Drawing.Imaging.ImageFormat.Gif);
break;
case 3:
this.button7.Image.Save(fileStream, System.Drawing.Imaging.ImageFormat.Bmp);
break;
}
fileStream.Close();
}
}
|
|
|
|
|
I think the error is here:
vijaywithu wrote: System.IO.Stream fileStream = (System.IO.FileStream)save.OpenFile();
For whatever reason, the OpenFile has returned a null Stream (Did you press cancel?)
|
|
|
|
|
Two things:
1:
SaveFileDialog save = new SaveFileDialog();
save.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
save.Title = "Save the File";
if(save.ShowDialog() == DialogResult.OK) Use this to prevent exception on Cancel click
{
string fName = save.FileName;
if (save.FileName != "")
{
System.IO.Stream fileStream = (System.IO.FileStream)save.OpenFile();
switch (save.FilterIndex)
{
case 1:
this.button7.Image.Save(fileStream, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
case 2:
this.button7.Image.Save(fileStream, System.Drawing.Imaging.ImageFormat.Gif);
break;
case 3:
this.button7.Image.Save(fileStream, System.Drawing.Imaging.ImageFormat.Bmp);
break;
}
fileStream.Close();
}
}
}
2: Set Buttons Image Property !!!
|
|
|
|
|
Hi
I have made a report to print a Bill. every thing is working properly but Hight of Table varries according to the no of items.
I m putting Partnos , description , qty, rate, total in TABLE BODY section.
I have used footer section of TABLE control for tax and total amount display.
I have fixed 8 rows/ page.
when 8 rows r in report Tax comes at right place but when 2 or 3 rows r thier then Tax section comes immediatly after item rows.
I want it to come at fix place.
PLease help me out this problem.
Thanks in advance.............
Amitendra
amitendra
|
|
|
|
|
Not sure if this is right, you have a footer to the TABLE that will be based on the table content. I think you need a PAGE footer to do the fixed position at the bottom of the page.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I've got this issue with loading an assembly from a byte array.
What happens?
First I create an assembly from C#-code which is generated. Then I stream the assembly to a byte[] and store this array in the database (column type = image, MSSQL 2000).
When I need the assembly, I retrieve the byte[] from the db and want to load it. I try to load the assembly using Assembly.Load(array), and then it breaks. For some strange reason my VS decided to give me a Dutch error while my language is set to English:
{"Could not load file or assembly '169 bytes loaded from FormuleCompiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Poging om een programma te laden met een onjuiste indeling."}
Which I think translates to:
{"Could not load file or assembly '169 bytes loaded from FormuleCompiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."}
I'm having trouble finding a good solution for it, as I don't know where it goes wrong. It all happens in the same namespace, by the same package. So the creation, streaming and loading happens in the same dll.
Source I use is below:
public CompiledFormula GetCompiledFormula(string cstext)
{
Assembly ass = Compile(cstext);
CompiledFormula result = (CompiledFormula)ass.CreateInstance("Compiler.COMPILEDFORMULA");
return result;
}
The byte conversion as follows:
public byte[] GetArrayFromAssembly(Assembly formula)
{
byte[] assembly;
try
{
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
{
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
formatter.Serialize(stream, formula);
assembly = stream.ToArray();
}
catch(Exception ex)
{
throw ex;
}
}
And this is the loading routine:
public CompiledFormula LoadFormuleFromAssembly(byte[] array)
{
try
{
Assembly assembly = Assembly.Load(array);
CompiledFormula formule = (CompiledFormula)ass.CreateInstance("Compiler.COMPILEDFORMULA");
return formule;
}
catch (System.Exception ex)
{
throw ex;
}
}
Anyone has an idea? Also, tell me if I make a horrible mistake here
The consumer isn't a moron; she is your wife.
|
|
|
|
|
I would be hugely suspicious of your serialisation code. A 169 byte assembly sounds very, very small to me.
Unfortunately, I have no idea how to convert a dynamically created assembly to a byte array (short of using AssemblyBuilder.Save then loading it in from disc).
Not being much help I know, but I can't believe you can use BinaryFormatter.Serialize to save the MSIL of assembly to a stream like that.
Regards,
Rob Philpott.
|
|
|
|
|
The assembly created, as it is now, is a 1 function class which on disk is no more than a 10k .cs file. The dynamic part is the function body which is generated. For me, I think the problem can either be in the byte array generation (the point of your suspicion), or at the load routines. I'm still considering namespaces to be an issue too, but haven't gotten any proof of me being right or wrong.
The hunt continues...
The consumer isn't a moron; she is your wife.
|
|
|
|
|
was carrying a variable trough sessions but realised that my code seemed to be better functional without these, so now am wondering how else i can carry my variable across multiple methods without making it global
|
|
|
|
|
There is the ViewState collection object, similar to Session, with the only difference that object stored in ViewState must be Serializable.
|
|
|
|
|
Exept for ViewState is for a single page. If this is a simple type (i.e. int, string, bool) I would just store it using cache or query string. But if it is a simple type storing it in session is a viable option as well.
|
|
|
|
|
The guy talked about accessing a variable across multiple methods. I assumed that he meant "multiple methods on the same page".
|
|
|
|