|
I am trying to map my ArrayList of type CRelation to data grid. CRelation class has two properties Child and Parent, both are of type CTable
<br />
public class CRelation<br />
{<br />
public CRelation()<br />
{<br />
}<br />
private CTable m_oPrntTbl;<br />
public CTable Parent<br />
{<br />
set {m_oPrntTbl=value;}<br />
get{return m_oPrntTbl;}<br />
}<br />
private CTable m_oChldTbl;<br />
public CTable Child<br />
{<br />
set {m_oChldTbl=value;}<br />
get{return m_oChldTbl;}<br />
}<br />
}<br />
<br />
<br />
public class CTable <br />
{<br />
public CTable()<br />
{<br />
}<br />
<br />
private string m_szName;<br />
public string Name<br />
{<br />
set{m_szName = value;}<br />
get{return m_szName;}<br />
}<br />
}<br />
<br />
Now i want to map the grid column to Name property of the Child
I am using following code to map the property
<br />
DataGridTextBoxColumn dgcCol = new DataGridTextBoxColumn();<br />
dgcCol.MappingName = "Child.Name";<br />
Code above does not work.
Am i doing something wrong here?
Thanks
|
|
|
|
|
First of all, don't prefix your classes with "C". This is an obsolete naming convention in the .NET Framework and all other CLI implementations. It's important to remain consistent with the .NET Framework because it is a RAD environment (Rapid Application Development). Have any of the classes you've used in the .NET Framework Class Library started with "C" (sans classes like CollectionBase or Control )? You won't find a single one. Read Naming Guidelines[^] for more information.
Second, you really should read about the DataGridTableStyle.MappingName property. See http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFormsDataGridTableStyleClassTopic.asp[^]. In it, it states that the DataGridTableStyle.MappingName must be set to the class name that the ArrayList - or just a simple array - contains. Your DataGridColumnStyle -derivatives then just contain the property name like Name .
The documentation above gives an example using a simple array, but an ArrayList works the same so long as you contain only one type (more than one type causes the first type to be used and any other types will not be bound).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
hello,
I'm trying to take a string from a dialog box and pass it to another form, here's my code
password.cs
<br />
...<br />
private String tmpPassStore;<br />
...<br />
private void pass_ok_Click(object sender, System.EventArgs e)<br />
{<br />
tmpPassStore=this.passText.Text;<br />
Form1.changePass(tmpPassStore);<br />
}<br />
form1.cs
<br />
...<br />
public String DBPassword ;<br />
...<br />
public void changePass(String pwd)<br />
{<br />
this.DBPassword=pwd;<br />
}<br />
but at compile time, I receive the following error:
D:\Projects\myBusinnes\password.cs(120): An object reference is required for the nonstatic field, method, or property 'myBusinnes.Form1.changePass(string)'
why??? I pass an object of type string...
Thanks in advance
Paolo
|
|
|
|
|
The compiler doesn't complain about the string.
To call the nonstatic method "changePass" of your "Form1" class you need an object of this class.
www.troschuetz.de
|
|
|
|
|
and excuse me how do I fix that??
Form1 calls password's form creating a new instance of the password object, how do I tell password's one to relay to form1 object?? thanks
Paolo
|
|
|
|
|
2 options:
1) Pass a reference to Form1 into the password form
2) Pass a delegate into the password form allowing callback to Form1
|
|
|
|
|
It's not working because Form1 doesn't exist in the context of the Password form. "There is no reference to an object of type Form1."
In other words, in Form1, it created an object of type Password (form). Form1 knows everything public about the Password object. The Password object, on the other hand, knows nothing of the object that created it (Form1). As a rule of thumb, Parent objects create child objects, know everything about them, and can manipulate them. Child objects know nothing of the parents that created them and, hence, can't directly modify them.
3rd option... Create a Public field on the Password form and have Form1 look at that field and retrieve the string itself. Instead of trying to pass the string from the Password form to Form1, have Form1 pickup the string from the Password form.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello all,
I need to set the Initinal date in the DatetimePicker Control Blank not to today.
Thanks
Hay
|
|
|
|
|
It can't be blank. The DateTimePicker.Value is of a DateTime type, which is a value type. Value types cannot be null.
What you could do is make it appear that it has no value by using an empty DateTimePicker.CustomFormat property value and handling the ValueChanged event. When the Value changes to, say, DateTime.MinValue then set the DateTimePicker.Format to DateTimePickerFormat.Custom . Using a similar approach should give you the appearance of a blank date. You may need to use a value different from MinValue depending on the validation for the default DateTimePicker implementation. Whatever is outside the scope of your application would work.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello,
1) Create a Form
2) Add a TabControl
3) Add a AxWebBrowser Control on a TabPage
Run the app, everything works correctly.
Change the StartPosition property to WindowsDefaultBounds
Run the app, the form has strange dimensions Why?!?
Any idea?
Alberto Bencivenni
devDept Development Team Leader
Topology Optimization | Finite Element Method | Cad/Cam | OpenGL | Programming
|
|
|
|
|
hey...i have a bluetooth receiver attached to my PC's USB port. How can i access it through code...I wanna do things like search for devices in the raqnge, change the visible/invisible status, turn the device on on/off etc?
|
|
|
|
|
hey...could anyone tell me what are interface and how do u use them...eg Idisposable, Iserializable. Simplicity would be greatly appreciated.
Thanks
|
|
|
|
|
Interfaces are contracts that ensures your implementation (either a struct - though not a good idea, unless required because of boxing when casting to that interface - or a class or another interface) implements a certain method, property, or event. Read 13. Interfaces[^] in the C# Language Specification for more details, including the difference between implicit and explicit interface implementations.
As far as how to implement certain interfaces - or rather what they do - you really need to read in the .NET Framework SDK[^] what they do. Many of the topics in the SDK documentation give examples, and there's always more abstract documentation (about how to use Framework features, like serialization and the disposable pattern) if you read Programming with the .NET Framework[^].
Reading is important. Just guessing what they do would teach you the intricacies of how those interfaces work with other classes (like how IFormatter implementations use the ISerializable interface, and that Types must be attributed with the SerializationAttribute to be serializable - ISerializable just allows you to custom serialization of your Type).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Interfaces are the public methods/properties/events a class must have (exact same signature) in order to implement them.
For example, any class that implements IDisposable MUST implement 'public void Dispose()' method
You can cast any object into any interface it implements making it useful, among other many things, as a way of achieving polymorphism (dont know if thats the exact term in english).
|
|
|
|
|
Skynyrd wrote:
For example, any class that implements IDisposable MUST implement 'public void Dispose()' method
That's not the only option. You can also implement it explicitly, which is how the disposable pattern recommends:
public class MyDisposableClass : IDisposable
{
public MyDisposableClass() {}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
}
}
void IDisposable.Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
~MyDisposableClass()
{
Dispose(false);
}
} Skynyrd wrote:
You can cast any object into any interface it implements making it useful
That's not correct, either. You can cast any managed object to any managed interface it implements, but you can also cast any proxy object to any interface it may not implement in managed code if it is attributed with the ComImportAttribute . This tells the CLR to QI (COM's QueryInterface for the interface based on its compiler-generated IID (an interface GUID) - which should never be the case - or its GuidAttribute value (to remain fixed) - which is the highly recommend way of declaring interface (so that the IID never changes; for COM interop, this is required to actually refer to the interface your trying to QI for).
I know that's not the simple case the original poster was asking for, but it's still the correct information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
An interface is somehow like an abstract base class as it defines a set of methods, properties, events and/or indexers, which have to be implemented by inheritors, but doesn't provide an implementation for its members.
The big advantage of interfaces is the allowed multiple inheritance. So classes and structures can implement multiple interfaces and interfaces themself can inherit from multiple other interfaces.
If a class or structure implements an interface, it has to provide an implementation for all the interface members. E.g. if a class implemnts the IDisposable interface, it has to provide a Dispose method.
Does this help?
www.troschuetz.de
|
|
|
|
|
Certainly.
Interfaces are "standards" which every class implementing them has to meet.
If you had an interface "ICar", the classes "Ford" and "FIAT" both would implement "ICar".
Why? Because every car has to implement ICar, since ICar is the standard for cars.
This is so every car feels the same.
Even if you practised on a FIAT, the Ford still has Accelerator, Brakes, Engine, Transmission... which are defined in ICar.
If you choose to implement an Interface, you cannot implement only part of it - you have to go the whole way (the interface would be useless otherwise).
Say you want to create an application which is extensible via PlugIns. You would then define an interface for you plugin and application, so every plugin anyone writes fits into the "socket" on the application.
So, within that application, you can call "sendMessage" on every Plugin - but one Plugin may send the message via email, another one via FTP ...
I think you get the general idea
Cheers
Sebastian
|
|
|
|
|
I'm trying to create a 2nd AppDomain for handling remotingserver stuff. What am I doing wrong here:
AppDomainSetup info = new AppDomainSetup();
info.ApplicationBase = "file:///" + System.Environment.CurrentDirectory;
AppDomain dom = AppDomain.CreateDomain("DataHandler", null, info);
BindingFlags flags = (BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance);
ObjectHandle objh = dom.CreateInstance("CommunicationServer", "CCommunicationServer", false, flags, null, null, null, null, null);
Object obj = objh.Unwrap();
CCommunicationServer h = (CCommunicationServer)obj;
h.BeginRemoting();
Then I have the remoting server class which I have compiled as a dll:
public class CCommunicationServer : MarshalByRefObject
{
...
}
When I call dom.CreateInstance("...); I get an exception saying: Could not load type CCommunicationServer from assembly CommunicationServer.
Have I understod something wrong here? Should I use AppDomain.Load() or something? Can you please give me a basic example how to get a 2nd AppDomain running.
Thank you.
|
|
|
|
|
First of all, don't prefix your classes with "C". This is inconsistent with the .NET Framework. A good RAD (rapid application development) environment requires consistency. Read the Naming Guidelines[^] for more details. Hungarian notation is obsolete in the .NET Framework naming conventions (and CLI).
Is the CCommunicationServer class the fully-qualified class name? If it is defined within a namespace you must specify that as well. If you're getting a TypeLoadException then that indicates the assembly was loaded but the Type (your class) was not found. AppDomain.CreateInstance throws the FileNotFoundException when the assembly isn't resolvable. The documentation indicates as much.
You might also consider setting the AppDomainSetup.ConfigurationFile property to allow your application to use a .config file. These are more important than using them for Remoting configuration data as I mentioned in a previous post to you. You can also redirect assembly bindings and configure other runtime settins as well. It definitely leaves you open to other possibilities. And, once again, configuring your remoting server via a configuration file is far more flexible than hard-coding it. Read about the Remoting Settings Schema[^] in the .NET Framework SDK for more details.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks. Adding the namespace did the trick. My next problem is firing events from the 2nd appdomain to the "main" domain, and I'd like to know is that even possible, so that I don't waste my time?
And thanks also for the naming guidelines, I will check in to that. And now that I have the 2nd appdomain running, I will modify the remoteserver so that it'll use the configuration file. BTW, why is it so important to use AppDomainSetup.ConfigurationFile?
Thank you.
Here: Have a rose for you trouble
|
|
|
|
|
It is possible. And it's called... .NET Remoting. Remoting is a managed RPC framework for communicating between context boundaries. Separate AppDomains - whether they are in the same process or not - are most definitely context boundaries.
Fortunately, the .NET Framework implements a default cross-domain remoting channel but it's pretty limited. Some in-depth research into remoting should mention this, but you should find more information in Ingo Rammers "Advanced .NET Remoting". See http://www.ingorammer.com[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
how can u find out the program files directory in .NET eg (C:\Program Files)
|
|
|
|
|
System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
i do not know how to describe , my English is very poor, so i call it "code pucker" .
Like the vs.net's IDE , you can click the node which at left side of every "{" to pucker the code .
i am very interesting on it , but i am a beginner, i try to read the source code of SharpDevelop, but i feel it was diffcult to me, can you help me?
thanks very much!
|
|
|
|
|
has anyone seen a really great piece of auto complete code? For those of you who dont know what autocomplete is :
'Suppose u have a combobox in which u have a few items added to the collection like "Hello", "Hi" , "Doggone". Now when u type "H" in the box the combobox automatically fills in "ello" for you. So u dont have to type the entire word.
|
|
|
|