|
presuming your button is called btnNew :-
btnNew_Click(this.btnNew, EventArgs.Empty);
Another Post by NnamdiOnyeyiri l Website
|
|
|
|
|
Thank you for the help. This worked perfect.
|
|
|
|
|
As I am new to C# programming I was wondering if you could help me. Attached is a xml file that I am simple trying to display in a grid control on a Windows form program. Unfortunately I keep getting the following error
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
Additional information: Cannot create a child list for field fegdata.
Here is the code im using when a button is clicked.
DataSet dsFeg = new DataSet("fegdata");
string filepath = "C:\\FegData.xml";
dsFeg.ReadXml(filepath);
dataGrid1.DataSource = dsFeg.Tables[0];
dataGrid1.DataMember = "fegdata";
dataGrid1.CaptionText = dataGrid1.DataMember;
Any help would be greatly appreciated.
Peter
|
|
|
|
|
Do the following instead, as you have your DataSource set to the table and the DataMember referencing the DataSet name (completely backward):
DataSet ds = new DataSet("fegdata");
ds.ReadXml(@"C:\FegData.xml");
dataGrid1.DataMember = "tableName";
dataGrid1.DataSource = ds;
dataGrid1.CaptionText = ds.DataSetName;
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Is there a method for creating an IntPtr Struct to a byte array via a safe method??
|
|
|
|
|
not that im aware of, after all, isnt an Intptr a pointer to unmanaged memory? (or am i talkin rubbish?)
Another Post by NnamdiOnyeyiri l Website
|
|
|
|
|
Nnamdi Onyeyiri wrote:
isnt an Intptr a pointer to unmanaged memory
IntPtr is just a data type that has a size of 32bits when running on 32bit hardware and 64bits when running on 64bit hardware.
That just makes it suitable for representing a pointer into memory.
James
"My words but a whisper -- your deafness a SHOUT.
I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
i was close enough
Another Post by NnamdiOnyeyiri l Website
|
|
|
|
|
See the System.Runtime.InteropServices.Marshal.Copy() method. It itself is unsafe, but doesn't require you to implement this in an unsafe context. Other than that (implementing the unsafe stuff in another assembly so you can mark your assembly as safe), you would have to pin the address and do it yourself.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi,
Does anyone know any free syntax highlighting control for c# windows forms?
Thanks
|
|
|
|
|
You might want to check out SharpDevelop[^]
I think they have a syntax coloring editor, not sure if its specific to c#.
Cheers,
Kannan
|
|
|
|
|
I am declaring a variable holding an object, and a reference to that variable. Like so:
CWhatever oObject = new CWhatever("xyz");
CWhatever oReference = oObject;
Further more, I would like oReference always to refer to the object initially assigned to oObject. In C++ speak and using pointers, this would be something like
CWhatever * const pObject = new CWhatever("xyz");
Note it is not the object that is constant, but the reference.
I fail to find how C# supports such a restriction. Any clues (other than using managed C++)?
TIA,
Bernd
|
|
|
|
|
Its only valid at the class level (not the method level) but you can use the readonly keyword on your variable declaration. It will then be a compile error to change the reference outside of the constructor.
[edit]
duh forgot the handy example
class Test {
private readonly MyClass foo;
public Test()
{
foo = new MyClass();
}
} [/edit]
James
"My words but a whisper -- your deafness a SHOUT.
I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
|
Hi!
Is there any simple method to detect which Link on linkLabel has been clicked before context menu opening?
I've got linkLabel with context menu set to some contextMenu. When I click LMB, the linkLabel1_LinkClicked event fires ok. But RMB does not fire this - just contextMenu appears, without any info about current link. Any ideas?
h.
|
|
|
|
|
if you set the ContextMenu property back to null you should be able to handle the RMB event as you want, then use the ContextMenu's Show method to show the correct context menu.
James
"My words but a whisper -- your deafness a SHOUT.
I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972
|
|
|
|
|
It works!
I was sure it'll be easy.
Thanks
h.
|
|
|
|
|
Got some Rich Text, want it in a Word document after klicking a button
but have no clude howto do this, Crystal Reports rip the text apart...
any ideas ? have i overseen something ?
|
|
|
|
|
hi !
take a look at this:
<sdk>v1.1\Samples\Technologies\Interop\Applications\Office\Word
there is a small demo-application provided by the sdk-samples.
andi
|
|
|
|
|
sry, but i dont get the point....
i didnt find a similar directory, and also nothing in the help
|
|
|
|
|
I need to apply arithmatic operations on string i.e.
string1 = "12";
string2 = "10";
string3 = string1+ string2;
and now I want string3 to contain "22"
currently I'm using functions like Add(string1, string2) which is a pain.
The problem is that the above statement (string3 = string1+ string2) will concatenate the two strings not add them and overloading the + operator doesn't work. The compiler gives an error saying One of the parameters of a binary operator must be a containing type. If I make my own String class, the overloading works fine.
Anyone got any ideas?
thanks in advance...hasan
|
|
|
|
|
You have to convert them to a numeric type first.
string3=(Int32.Parse(string1)+Int32.Parse(string2)).ToString();
"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
|
|
|
|
|
right. But I don't want to have to convert the stings to ints every time as i'm using around 15 for each calculation and doing what you suggested would make the code sort of confusing.
I think it can be done using operator overloading so that the developer can add two strings simply by writing
string3=string1+string2
Anyone with some other solution?
|
|
|
|
|
public static string operator + ( string s1, string s2 )
{
return (Int32.Parse(s1) + Int32.Parse(s2)).ToString();
}
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Your solution
Ista wrote:
public static string operator + ( string s1, string s2 )
{
return (Int32.Parse(s1) + Int32.Parse(s2)).ToString();
}
doesn't work...I've had already tried it. The compiler generates an error: One of the parameters of a binary operator must be a containing type". So the + operator can't be overloaded in this way.
|
|
|
|