|
What's all this VB.NET code you're writing in the C# forum lately, Dave? Have you converted to the "dark side"?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I float back and forth, dark-side...light-side...
You really have to taste them both before you commit to one power or the other...
I was actually only trying on the black suit and cape with the funny respirator noise. I can't get the James Earl Jones voice to work though! Oh well...back to C# I go!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
I can't get the James Earl Jones voice to work though!
You won't sound like him with your helmet off.
C# vs. VB.NET: really, I don't care. Good developers (that includes you, of course) can switch back and forth realizing that it's only a difference in syntax (although knowing a little of that syntax is necessary, which I do I hate to admit). It's good to brush up on VB.NET syntax from time to time, but remember that even Luke stopped from killing his father before it was too late and he was completely turned!
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Oh! I found the problem! I forgot to change the batteries in my helmet!
I'm jumping back and forth between both forums... I just forget which one I'm in at the time. The same thing happens while I'm doing stuff in VS. I can be writing code in VB and suddenly start typing C# stuff or the other way around. Little red squiggly lines start poppin' up all over the place...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
OK. CHANGE THE CHANNEL!
--End of line
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Damn! VB code in the C# forum again!
OK...translated:
ListBox1.Items.Insert(0, "MyNewItemGoesHere")
try
{
ListBox1.Items.RemoveAt(25)
}
catch
{
}
What forum am I in again?? Damn! 35 years old and I can't remember which way is up!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I like to extend the TreeNode class through Inderitance to add a string property to the class. The TreeNode Class has 5 constructors, do I need to provide 5 contructors in my TreeNode class ? Is there some way I can pass a variable set of paramters to the base class's constructor ?
|
|
|
|
|
Guinness4Strength wrote:
do I need to provide 5 contructors in my TreeNode class
No, and you'll still be able to call those 5 constructors on your inherited class.
Guinness4Strength wrote:
Is there some way I can pass a variable set of paramters to the base class's constructor ?
Why? You can provide your own constructors that call the base constructors, and optionally, set various properties of the TreeNode while in the body of your constructor.
#include "witty_sig.h"
|
|
|
|
|
You only need to define the constructors that you want, but be sure to call the base class's corresponding constructor like so:
public class MyTreeNode : TreeNode
{
public MyTreeNode(string text) : base(text)
{
}
} Also be sure that you cast the TreeNode from the tree to your class (ex: MyTreeNode ) when you need to access that string. The TreeNodeCollection will store a reference to your derivative class, but will only return a TreeNode since that's all it deals with. That object is still an instance of your derivative class, though.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ok, thanks Heath.
I assumed I still needed to define the constructors in my class, but wasn't sure...
|
|
|
|
|
No, you don't have to provide 5 constructors for your TreeNode class. Since your extending the existing TreeNode class, all you have to do is supply your own constructor if one of the existing ones is not suitable. You could override the existing contructors to provide slightly different functionality, like filling in your extended fields with default data, or provide a completely new one so long as the signature of your constructor doesn't match an existing one.
If you wanted to provide a constructor that took two String parameters and an existing TreeNode object, instead of a single String and TreeNode, you could because there is no matching constructor in the base class constructor list.
public TreeNode( string text, string altData, TreeNode[] children );
Now, if you wanted to provide a new constructor that takes the same type and same number of parameters, like:
public TreeNode( string text, TreeNode[] children );
and
public TreeNode( string altData, TreeNode[] children );
Then you would have to rearrange your parameter list because you can't ahve two constructors with the same signature, in this case TreeNode(string,TreeNode[]) :
public TreeNode( TreeNode[] children, string altData );
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
By the way, if you are going to be doing a lot with tree controls, you might look at the Infragistics tree control. It's a bit expensive, but it has a lot more flexibility than the Microsoft standard tree control.
- Bruce
BRCKCC
|
|
|
|
|
Dave thanks for the response, I'm not sure if this got sent to you b4 or not but here it is again...sorry if its duplicated...
So now I'm alittle confused...
I have the following code:
MyTreeNode class implementation
namespace MyName
{
internal class MyTreeNode : System.Windows.Forms.TreeNode
{
private string ExtraLabel;
public string InternalLabel
{
get
{
return ExtraLabel;
}
set
{
ExtraLabel=value;
}
}
internal MyTreeNode()
{
ExtraLabel=null;
}
}
}
Instanciation
MyTreeNode Node = (MyTreeNode)new TreeNode(Drive,IconIndex,IconIndex);
I get an invalid cast exception thrown...what am I doing wrong ?
|
|
|
|
|
I think it's going to be more like this:
MyTreeNode Node = New MyTreeNode( parameters );
And when you add it to the Nodes collection in your TreeView:
TreeView1.Nodes.Add( (TreeNode)MyTreeNode );
And when you try an access that node, say, in reference to the TreeView's SelectedNode property:
MyTreeNode myNode = (MyTreeNode)TreeView1.SelectedNode;
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Well when I first created this class I tried your first suggestion;
<br />
MyTreeNode Node = new MyTreeNode(Drive, IconIndex,IconIndex);<br />
but it would not compile, I got an error indicating that no constructor for MyTreeNode took 3 parameters (which according to my class is true...My constructor takes 0 parameters). Hence my initial question about needing to create default consrtuctors in MyTreeNode class duplicating the base TreeNode Constructors. This is why I'm confused.
|
|
|
|
|
That's right, you have to supply your own constructor if your going to do this. The TreeNode class doesn't have a constructor that understands the parameters you gave it, so you have to supply one that takes those 3 parameters in your MyTreeNode class code, but you don't need to recreate the constructors of the base class, TreeNode. Just add you own contructor.
public MyTreeNode( string drive, Int32 iconIndex, Int32 iconIndex );
The Int32's should be whatever type your trying to pass into your constructor...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
ok, to recap:
I need to duplicate the base class's contructors in my inherited class's implementation if I use them in my inherited class.
If thats the case, and the TreeNode's constructor is suitable, then where does the following apply ?
Dave Kreskowiak wrote:
Since your extending the existing TreeNode class, all you have to do is supply your own constructor if one of the existing ones is not suitable.
|
|
|
|
|
When you need override the base class constructors and do some extra work that they don't. Your constructor will get called, then you do your extra processing or whatever, like setting default data in your version of the class, then you call the base class constructor with the same arguments that were sent to you.
Now, if you need to get parameters that the base class constructors don't support, then you have to supply your own constructor with the parameters that you need. But, don't forget to call an appropriate base class constructor, so it can do the setup work it needs to do.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Guinness4Strength wrote:
I like to extend the TreeNode class through Inderitance to add a string property to the class.
If it's only adding a string property, why are you inheriting the TreeNode class at all? You can use TreeNode's Tag property to 'tag' (associate) any object with your node, including a string.
|
|
|
|
|
Hi Gurus!
I got some troubles to fill Dataset...
I've added a Dataset.xsd file to my ASP.NET application. Then drag&drop some tables I want to retrieve data from. And after all I got such query
select code, package1.func(domain_cd, code, 'EN') as descr
from table1
The matter is that in PL/SQL developer this code works fine, but when I'm trying to run following code in C#
OracleDataAdapter da = new OracleDataAdapter(sql, con);
DatasetXSD= new DatasetXSD();
da.Fill(DatasetXSD, "table1");
an error occurs:
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
So I want to ask - do I need to set some relations in DatasetXSD during desing-time? And is it correct to use function in query to fill Dataset, or I should make it throught nested query? (I mean select code (select row1 from table2) as descr from table1)
xedom developers team
|
|
|
|
|
I recently experienced the same problem, and I fixed it by setting up relationships between the table in your schema.xsd file. Seems like your relationships in the schema file need to match those in the database itself to resolve issues like this. Hope this helps
Frank
cout << "Have a nice day" << endl;
|
|
|
|
|
ok, thanx. I have rebuild my query by adding some resaltions, so for now I am retrieving data from two tables, and I got inner join. MMy sql query looks like
select t1.code,
t2.name
from tab1 t1, tab2 t2 where t1.code=t2.code
Then I call DataAdapter.Fill(DatasetXSD);
no errors occured but DatasetXSD is empty, and when I run the same query in PL/SQL Developer everething works fine...
Maybe some one can tell me anoter way to fill Dataset from multiple tables correctly?
xedom developers team
|
|
|
|
|
If you have relationships established between a couple (or more) tables, your Fill statement won't work because you're only filling one table ("table1"). Make sure you fill the whole DataSet .
Your SelectCommand can contain multiple SELECT statements, delimited by semi-colons (just like in SQL).
Make sure you add table mappings, though. A DataAdapter will, by default, map to tables "Table", "Table1", "Table2", ... "TableN". See the DataAdapter.TableMappings property for more details.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
has anyone figured out how to get round the PrintToFile issue with .Net?
The PrinterSettings.PrintToFile property can only be set by the System.Windows.Forms.Printing.PrintDialog class. The Print to file option only appears on the System.Windows.Forms.Printing.PrintDialog when the System.Windows.Forms.Printing.PrintDialog.AllowPrintToFile property is set to true. For more information, see the KB article "'PrintDocument Class' Does Not Implement The PrintToFile Feature (820644)" on Microsoft TechNet, at Technet Article[^].
I really want to be able to print to a temporary file (using a pdf driver) for e-mailing.
Thanks in advance,
Gary
|
|
|
|
|