|
In VB6 I used the following code with no problems:
xlsheet.HPageBreaks.Add Before:=xlsheet.Rows(rowcnt)
In C# I don't know what parameter I'm supposed to pass to the HPageBreaks.Add method. I keep getting the error:
"Object must be a normal type and not an array"
I've tried passing it an excel range, and the row number with no success.
|
|
|
|
|
Hi all, hope you can help on this one.
I have a C++ struct like this below:
struct OTHERSTRUCT Thing[MAX_NO] = {
{1, "x"},
{2, "xx"},
};
where OTHERSTRUCT is:
struct OTHERSTRUCT
{
int Num;
CString Desc;
};
My question is how do i replicate this in C#? the only way i have so far got this to work is shown below:
public struct tagLINE
{
public tagLINE(int ACode, string ADesc)
{
Code = ACode;
Desc = ADesc;
}
int Code;
string Desc;
};
And creating an instance of it like this:
public tagLINE[] A = new tagLINE[3] {new tagLINE(0, "0"),
new tagLINE(1, "1"),
new tagLINE(2, "2")};
Do i really have do all this "new"ing? Any feedback would be
great.
Simon Wren
simon.wren@nesltd.co.uk
C++ Application Team Leader
National Energy Services Ltd
Visit Us: www.nesltd.co.uk Or: www.nher.co.uk
|
|
|
|
|
Simon Wren wrote:
Do i really have do all this "new"ing?
yes
PS: everything else looks fine
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
So, normally a structure is not new'd when instanciated, except when it's going into an array? This means that the array can only hold reference types, right? Are the value types actually boxed as they're added to the array?
I appreciate you sharing your knowledge on this stuff or pointing me somewhere that explains it better.
Regards,
Alvaro
Can I ask you a question?
|
|
|
|
|
I was under the impression that new was optional for structs. Try getting rid of the constructor altogether and assigning directly to the structures values. Don't see why it wouldn't work.
|
|
|
|
|
I'm working on an application for a school. The web based application needs to give teachers (some teachers have been assigned organizational units) the ability to edit certain group policies. How would I go about getting an object for the "Proxy settings" policy. it seems like the api function GetGPOList might do it, but I'm somewhat lost.
|
|
|
|
|
Hi all,
I have a serializable class 'A' which contains a ArrayList. I create a new instance of class 'A' and add a new instance of Serializable class 'B' to the arraylist.
Now when I try to Serialize class 'A' with BinaryFormatter it just dies..no errors, no crashing.I've marked the statements in vs.net and it just stops when it hits the line that serializes it. Im only attempting to serialize class 'A' thinking that it should serialize all classes its linking to automatically? is this correct?
I have no idea why this is happening and have been struggling with it for a few days now, has anybody got any ideas?
Thanks,
Matt.
|
|
|
|
|
For me it works.
I have
[Serializable]
class A
{
B[] arrayOfB;
}
[Serializable]
class B
{
}
Perhaps it's because you haven't set the Serializable attributes to all? Or because you are using an arrayList? Try with a simple array to check
|
|
|
|
|
Things to check
You will need [Serializable] attribute on each class (should throw an exception, not hang), if it still doesnt serialize, the objects could be far to complicated to serialize, I have had a problem using the binrary formatter on certain complicated objects, it looses data and generally is unstable (I think this was in release 1.0, I Havent tried in 1.1).
Theres a handy undocumented class called LosFormatter, i think its in the System.Web namespace, its a very agressive serialization class which can serialize more data types than the binary formatter. Use it in exactly the same way you would use the BinaryFormatter class.
FYI: LosFormatter is what is used to generate the ViewState field in an ASP.NET application. I cant guarentee it will solve all your problems tho
Thanks - James
James Simpson
Web Developer
imebgo@hotmail.com
|
|
|
|
|
That led me to add extra logging through the process, and I found that it dies when i add to the collection, rather then when it serializes.. turned out to be that I didn't initialize the arraylist d'oh!
It seems to always be something simple that I totally overlook.
Oh well, thanks for the reply (:
|
|
|
|
|
I evaluated seven xp style menus - none of them does MDI merge. Conspiracy?
Tomaz
|
|
|
|
|
I want to Drag files from a TreeView from my application into Windows Explorer. I know hw to get Drag Drop data from windows Explorer but I don't know how to do it from my application to explorer.
Mazy
No sig. available now.
|
|
|
|
|
Start the drag operation with:
treeview.DoDragDrop(new DataObject(DataFormats.FileDrop,files),DragDropEffects.All);
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Thanks for reply.
The problem is here what is the second parammeter of DataObject should be. I think it should be kind of stream.
Mazy
No sig. available now.
|
|
|
|
|
An array of file names, maybe?
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
jdunlap wrote:
An array of file names, maybe?
ya.
Mazy
No sig. available now.
|
|
|
|
|
I have a class that contains two variables.
Class Toto
{
public int Var1;
public string Var2;
}
I serialize this class through a binary formatter.
Everything runs fine.
Now, I want to add a new var to my class
Class Toto
{
public int Var1;
public string Var2;
public string Var3;
}
If I try to deserialize my previously saved bin, I got an error.
Is there a way to deserialize an "old version" of the class, reading only the fields that existed at the time of serialization, and leaving the new fields empty?
|
|
|
|
|
Hi guys,
I am trying to create TCP Listener windows services using C# to listen to a local TCP port continuously.
I have written a windows console application which does the job properly but when I convert it to windows services it did not work, as you know definitely I can not use infinity loop on the OnStart method but I want the services to keep listen to synchronous connection by a client and send response when data received.
The senior as following:
I want to listen to a port which I will receive a string 200 characters from a client then send response as acknowledgement.
Your response is highly appreciated.
Regards,
|
|
|
|
|
I posted a response to your first post a few pages into this forum.
Cheers - James
James Simpson
Web Developer
imebgo@hotmail.com
|
|
|
|
|
When an load event occur, you can call the function [FormName]_Load(object sender, System.EventArgs e) to deal, also or call the function On_Load(System.EventArgs e). What's diffrent between them?
=== Game is power! ===
|
|
|
|
|
YourForm.OnLoad is an override of Form.OnLoad , which actually raises the event. Using this override would, for example, allow you to prevent the event from being fired, by not calling base.OnLoad .
YourForm_Load is an event handler for the Load event and allows you to perfrom some action when the Load event occurs. To follow the previous example, you would not be able to prevent the event from being fired as it already has been.
Derek Lakin.
The great thing about being a slayer: is kicking ass is comfort food. Buffy
Salamander Software Ltd.
blog: Digital Thoughts
|
|
|
|
|
I am trying to write a char in hexadecimal format to a binary file. I'm using the following:
FileStream fs = new FileStream("test.bin");
BinaryWriter bw = new BinaryWriter(fs);
char c = '\xABCD';
bw.Write(c);
What I get in the file is EA AF ..... instead of expected
AB CD ......
Any ideas?
Thx.
Samo.
|
|
|
|
|
What's happening is that, by default, the character is being written out in UTF-8. If you want to just write out the character as if it were a ushort, either cast it to a ushort, or change the encoding for the binary writer.
By the way, writing out the ushort 0xABCD to a file will produce 0xCD 0xAB in that order.
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
Is it possible for calls to Socket.Send() to block?
If a socket "s" has s.Available > 0, and one calls s.Receive() with a read length of s.Available, can the call to s.Receive() block?
If blocking is possible in the situations described above, is there a way (without using asynchronous I/O) to determine in advance which calls will block, and/or avoid blocking?
Andrew
|
|
|
|
|
I want to match and replace a character sequence in the middle of a string, but the same sequence could appear at the begining or the end of the string as well and should be left alone. So for example:
Regex r = new Regex("a");
will match all occurences of "a" in a string, but:
Regex r = new Regex("^a");<br />
will only match "a" if it occurs at the begining of the string, and:<br />
<code>Regex r = new Regex("a$");<br />
will match it at the end. The trouble is I want to match "a" when it doesn't appear at the begining or the end of a string. There doesn't seem to be a way to say not begining and not end though? Does anybody know if such a thing is possible? I could use:<br />
<code>Regex r = new Regex(".a.");
but that will also match the character before and after the "a" which I don't want to replace.
Cheers
WJ
|
|
|
|