Antenka 274 Posting Whiz

Hello, HBMSGuy.
Are you sure, that you have error about passing derived class when method asks the base one? Only thing, that I see it's a few mistakes (in other area):

Class TaskToRun
{
     public virtual void run ();
}

here if you don't specify any functionality to the method 'run', call the calss (also as this method) as abstract. Or add empty brackets pair: { } - if you want to leave it as virtual.

Class SayHi : TaskToRun
{
    public run()
    {
        Console.WriteLine("Hi");
    }
}

if you decided to make your base class abstract, you should add 'override' keyword to method run . Also the return type is also needed :P
if you decided to leave your method in base class as virtual - you have 2 ways to go:

Warning 'SayHi.run()' hides inherited member 'TaskToRun.run()'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.

RunTask(TaskToRun task)
{
   delegate void MethodToRun();
   MethodToRun methodtorun = new MethodToRun(task.run);
   methodtorun();
}

The delegate declaration should be at class level (like you would declare variable in the class) .. or higher - in namespace. You decide.
Also there're some notes about initializing and calling it. Look here, there is good example: delegate (C# Reference).

Well, here's what we have in result (my version):

delegate void MethodToRun();

class TaskToRun
    {
        public virtual void run() { }
    }

class SayHi : TaskToRun
    {
        public override void …
Ramy Mahrous commented: Ideal answer (Y) +7
Antenka 274 Posting Whiz

Well, let's look closer to example given there (I mean the points of attention):

//create a model
final DefaultListModel model = new DefaultListModel();

//creating JList based on our model
JList list = new JList(model);

//add element to the model
model.addElement("Element");

This 3 lines describes all the process: working with JList using model (look at MVC pattern).

So, we can make this example even more simple:

public static void main(String[] args)
    {
	final DefaultListModel model = new DefaultListModel();
	JList list = new JList(model);	
       //adding 2 elements
       model.addElement("Element 1");
       model.addElement("Element 2");


	JFrame frame = new JFrame("DefaultListModel JList Demo");
	JScrollPane scrollPane = new JScrollPane(list);
	frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
	frame.pack();
	frame.setVisible(true);

    }
peter_budo commented: Nice examples +17
Antenka 274 Posting Whiz

Well, there're plenty of examples there to play about and understand :)

Antenka 274 Posting Whiz

Hello, Peg.
Look there: DateTime Structure

Antenka 274 Posting Whiz

In one of the links, that I gave you (Advanced JList Programming) there is a potion for you. "Lists with Dynamic Contents" .. with example to play around :)

Antenka 274 Posting Whiz

Well, if your client-server interaction part works fine (I mean, that you're able to establish connection and transfer some data). Then all you have to do is somehow (depends on in which view you want to keep it in the JList) parse your data to add into list or withdraw from it.

Some examples of using JList you can find here:
Class JList
Advanced JList Programming

Antenka 274 Posting Whiz

:) good luck

Antenka 274 Posting Whiz

Hello, skiing.
As Ezzaral said, for comparing objects of self-created data types, you need to add realization Comparable interface in that class. In other words - you're kinda saying "The objects of my class, called 'TreeNode" can be compared with each other using CompareTo method." Let's look at example:
Suppose we have class Apple (with some variables and methods):

public class Apple
{
    //indicates, how green apple is
    private int _greenLevel;
    //size of the apple
    private int _size;
    //sort of the apple
    private String _sortOfApple;

    public int getAppleSize() { return _size; }

    public Apple(int greenLevel, int size, String sortOfApple )
    {
        _greenLevel = greenLevel;
        _size = size;
        _sortOfApple = sortOfApple;
    }   
  etc.
}

And imagine, that I need to compare the objects of my Apple class e.g. by the level of the green. Then my class needs small changes:

public class Apple implements Comparable

and now I need to realize the "CompareTo" method (as Comparble demand from me):

public int compareTo(Object o) {
       if (this._greenLevel > ((Apple)o)._greenLevel)           
           //this object is greater than given
           return 1;
       else if (this._greenLevel < ((Apple)o)._greenLevel)
            //this object is less than given
            return -1;
        else
           //objects are equal
           return 0;
    }

Now we can freely test that in main method:

public class Test
{
    public static void main( String args[] )
    {
       Apple app1 = new Apple(2, 4, "Asort");
       Apple app2 = new Apple(5, 8, "Asort");
       System.out.println(app1.compareTo(app2));
    }
}

That will give us "-1" in output (as expected, because the …

Antenka 274 Posting Whiz

Hello, pjpro.
There're some variables/methods in your code, that you use but haven't declared (such as "ListDemo", "display", "enter"). That is the source of the compilation errors.

If I was you - I'd use another strategy to develop:
1. Write simple code for client-server interaction.
2. Increasing this code step by step by a little portions.

That will help you to understand better what you're doing there (also as to have better control over it :P)

Antenka 274 Posting Whiz

Hello, prashantsehgal.
This might be helpful for you:
New Microsoft Chart Controls for Web and Windows Forms Applications
A flexible charting library for .NET

A WPF Pie Chart with Data Binding Support
OpenWPFChart: assembling charts from components: Part I - Parts

hope,that that is what you're looking for :)
P.S. you can find much more examples there :)

Antenka 274 Posting Whiz

Hello, foxypj.
Please, try to put there some effort ... your tries, suggestions and such.
The main thing in my help is that I'm trying to push you in right direction (or show the possible ways to go) to get your solution. I can't push you if I have no idea: are you moving in a right way or my explanation leads you in wrong direction .. or maybe you're standing on the same place and waiting for ready-made solution :P

Antenka 274 Posting Whiz

then when you click my save button i need it to take the information from any boxes that have changed. and change the appropriate line in the .txt file. i am really new to C# and this program is really hard.

Well, let's imagine the algorithm of this:
1. Memorize the initial state of your combo-boxes and after pressing the button - check if it changed.
2. If it changed - go to file, find the line and change the values there ...

For finding the certain line in file, you should iterate through your file and check the lines, if they are fit to your condition.

Then if the line, that you're going to change and new line has same length, then you can rewrite that line, by seeking and setting the certain position of where to write.

But if not ... In that case - you should, e.g. memorize the data after the line, that you gonna change, rewrite that line and then after that line, write the data, which you memorized before.
Is that what you're looking for?

Antenka 274 Posting Whiz

Hello, try to look at TimeSpan Structure.

Antenka 274 Posting Whiz

For millions different cases for counter value - I'd better used switch.
The second thing, that I've wanted to point to is this:

output = line;
mcodecombo.Items.Add(output);

Are you sure, that you need to re-assign the value of line variable to the output and then add it to the mcodecombo? Maybe it's better to do this:

mcodecombo.Items.Add(line);

for this:

i then need to make it so that when you click the item in the combobo it populates the other text boxes with the appropriate lines

you should check the ComboBox Events and find the most suitable event for your need. And then write the code for it.

Antenka 274 Posting Whiz

Hello, can you post what you have so far? Any tries in code, which 'don't want to work proper'.

Antenka 274 Posting Whiz

:D you're welcome

Antenka 274 Posting Whiz

Hello, ddanbe. All you have to do is add your BinCB to the list of Controls of your form:

this.Controls.Add(this.BinCB);
ddanbe commented: I could have known this but thanks for reminding! +4
Antenka 274 Posting Whiz

Hello, in your case you should at first initalize array1[0], and the access it variable 'array2[0]'.

array1[0] = new MY_TYPE2();
Antenka 274 Posting Whiz

Hello, VelcroMan.
There is one (that I know) method to do that. Here: Regex.Unescape Method

P.S. But you should pay attention on this part:

Of course, Escape cannot perfectly reverse Unescape because it cannot deduce from an unescaped string which characters may have been previously escaped.

Antenka 274 Posting Whiz

Hello, milgo. You have in your program definition of a Product class. And as far as I understood, you was going to use it in Inventory class. But instead of that, you're creating an instance of Item:

//Instantiate an Item object
Item myItem = new Item();

By the way, there're a lot of small errors: you wrong typed a methods names (java is case-sensitive).

Antenka 274 Posting Whiz

Hello, konczuras. I think that this article will help you to make out with using reference and value types and ways of passing them into methods:Passing Parameters

Antenka 274 Posting Whiz

Hello, charlie81. Well, you have class Main_Class, which has method public static void main(String[] args) (which is an entry point into your program). And in that method you're defining new class with it's own entry point.
In the program can be only one method main.

Antenka 274 Posting Whiz

Well, if follow your's app logic: the Category must be a part of the Item (belongs to it). So if I were you - I would place the definition of it in Item class. And then import it from that class for using in Tester class.
Hm ... sounds strange. But it's the only thing that I can suggest now :)

kbullard516 commented: Very Helpful +1
Antenka 274 Posting Whiz

Ok, in this place you can use simple construction, like:

category = eCategory.valueOf(scanToken.next());
Antenka 274 Posting Whiz

Hello, kbullard516. I was playing around with your code. Here's what I have so far:
(simply I've turned your words in code :P )

public int compareTo(Object other)
{
       String otherName = ((Item)other).getName();
       eCategory otherCategory = ((Item)other).getCategory();
       int otherQuantity = ((Item)other).getQuantity();
       double otherPrice = ((Item)other).getPrice();

       //if category's are equal       
       if (category.equals(otherCategory))
       {
           //if quantity's are equal
           if(quantity == otherQuantity)
           {
               int r = name.compareTo(otherName);
               
               //if names are equal
               if(r == 0)
                    return 0;
               else
                   return r;
           }
           else
                if(quantity > otherQuantity)
                    return 1;
                else
                    return -1;
       }
       else
       {
            return category.compareTo(otherCategory);
       }
}

Almost your code with little addition: I decided to use enum type for category:

enum eCategory
    {
        C,
        W,
        M
    }

That made more simple comparison of categories. So you free to choose: or use that enum

and a bit modify entire prog or add comparison for your categories :)

P.S. That's not the best example, but I think it's better than nothing :P

Antenka 274 Posting Whiz

Good luck :)

Antenka 274 Posting Whiz
Antenka 274 Posting Whiz

Ok, let's see ... your array2 in any case has value { 'X', 'O', 'X', 'O', 'X', 'O', 'X', 'O', 'X' } (even if users during the game entering the 'X'/'O' in other order). To make it more obvious (same data in table view):
X | O | X
----------
O | X | O
----------
X | O | X

And you check THIS table for matching your conditions (not entered by user).

Antenka 274 Posting Whiz

Hello, cause&effect.
Just to add to Rashakil Fol's words: your array2 is specific view of your gaming board. That mean, that every value in it depends not only on who belongs the turn to, but also on a position, where to store 'X' or 'O'. You already use that to check the condition (e.g. (array2[0] == array2[2] && array2[0] == array2[1]) ... mean, that you're checking if the 'X'/'O' are placed in 1,2 and 3 fields).
But you don't use that to store data into array:

if (i % 2 == 0)
{  
     array2[i] = 'X';

Take that into account :)

Antenka 274 Posting Whiz

Hello, drfarzad.
1. You call the Console.ReadLine(); and don't assign the value, entered by user to any of variables.
2. You miss a letter in the word 'Convert'.
3. You don't 'memorize' any of the pressed keys.
4. Same as in 3.

Antenka 274 Posting Whiz

Hello, rasingh24.
I suppose, this should be helpful for you: TreeViewEventArgs..::.Node Property

P.S. All you have to do to get any data of the selected node - is extract it from e.Node .

Antenka 274 Posting Whiz

:) Good luck!

Antenka 274 Posting Whiz

Hello, C#Newbie.
If I were you, I'd probably made some changes in format of the file. E.g. place info about single friend on a single line (using specific separator between the fields, like tabulation symbol, or something like that). So if we'd have 10 friends - it would be 10 lines in a file. Then would make a constructor, that takes a string as parameter, parses it and fills new object with data. And I'd better used List instead of ArrayList. Here is what I'm talking about:

// Same array, but each element would be of Friend type.
List<Friend> friendArray = new List<Friend>();

//adding new friend to an array, and for creating new one, we're using
//line, that we'd read from the file.
friendArray.Add(new Friend(line));

But if you don't like that one :P, here is one more (which is closer to your code):
1. You should add to your ArrayList not 'line', but a new created Friend object.
2. For adding new Friend object, you should fill it by data. You choose how to do that: in constructor, or in some method ...
Doing that way, you'll be able to do this:

foreach(Friend fr in friendArray)

because your friendArray now consists from strings, and not from Strings, as was before.

Antenka 274 Posting Whiz

Hello, C#Newbie. Try to add Flush before closing your StreamWriter.

in your case it's:

output.flush();
Antenka 274 Posting Whiz

Hello, jobi116.
As one of the solutions, I can offer this to you:
there is one function : SHGetFolderPath (shell32), that can help you get the path to 'special' folders, like you are listed. Here you can find much more such folders.
Also there is some class in .Net, that allows you to get path to some of that folders: Environment.SpecialFolder Enumeration.

So all you have to do - catch the 'special' folder and do not add it into your treeview.

P.S. I had some troubles getting the path to the Control Panel, so if you'll get something like that - we'll invent something else ;) Good luck.

P.P.S. If you want to investigate more in using shell, look here:
C# does Shell, Part 1
C# does Shell, Part 2
C# does Shell, Part 3
C# does Shell, Part 4

Antenka 274 Posting Whiz

Hello, ddanbe.
I hope this will help to solve your problem: Remove current record triangle from DataGridView RowHeader??

:)

Antenka 274 Posting Whiz

I solved this. I moved my database (with dataset, adapters) into new (non-startup) project in the same solution and it's working now :) Unfortunately I have no explanation of that O.o

Antenka 274 Posting Whiz

I use Express edition.

Antenka 274 Posting Whiz

When you call this:

tail = Counter(tail);

variable tail not gonna change. Your initial value of tail is 0 and if you'll divide it by some number - it will give you 0.

Antenka 274 Posting Whiz

yes

Antenka 274 Posting Whiz

InsertCommand value is "INSERT INTO [ReferenceCycle] ([name]) VALUES (@p1)". DataSet is also generated by VS (if you're talking about that).

Antenka 274 Posting Whiz

Hello, Ramy.
Thanks for helping me :) newCycle has string type. The InsertQuerry I've created by adding queries in Wizard. My table ReferenceCycle consists from 2 fields (cycleId - It counts automatically; name - string, that I pass as argument into InsertQuerry method).

Also, my DataSet is changing perfectly. The only thing - is that I can't pass changes, that I've made, to database :(

Antenka 274 Posting Whiz

Hello, everybody.
I have typed DataSet ( dsMain ), that contains table ( ReferenceCycle ). In the program I make changes in that table, using generated by VS typed table adapter ( taReferenceCycle ) and values seems to gets inserted. And when I'm trying to update database with this - nothing happens. Here's part of my code:

taReferenceCycle.InsertQuerry(newCycle);
taReferenceCycle.Update(dsMain.ReferenceCycle);
dsMain.ReferenceCycle.AcceptChanges();

What am I doing wrong?
Any help would be greatly appreciated :)

Antenka 274 Posting Whiz

When you do this:

Person vn = new Person("dingh","Ding");

you initialize only two fields, calling this:

Person(String brukernavn, String navn) {
        this.brukernavn = brukernavn;
        this.navn = navn ;
    }

and on the stage, when you trying to print info, you ask this

Venn p = forstevenn;
        while(p != null) {
        //....
        }

but forstevenn is non-initialized (is null).

Antenka 274 Posting Whiz

Hello, winky.
I don't see definition of groupBoxes in your code. Before using variable, you should define it with some type, like you do this here:

WeatherForecasts weatherForecasts;

For initializing GroupBox you could use example from here: GroupBox Class. Also about other components: System.Windows.Forms Namespace.

Antenka 274 Posting Whiz

Hello, jobi116.

how to make all the child node checked when parent node is checked. i tried this but only first 2 child nodes get checked.. here's what i tried.

Here is an example: Check child nodes in a tree view control

how to bring the system directory's in tree view.

I think this would be interesting to you:
An "Explorer-Style" TreeView Control

Antenka 274 Posting Whiz

Check for this (msdn):

If visual styles are enabled and EnableHeadersVisualStyles is set to true, all header cells except the TopLeftHeaderCell are painted using the current theme and the ColumnHeadersDefaultCellStyle values are ignored.

I've tried to set the EnableHeadersVisualStyles to false and it's working.

ddanbe commented: Nice. +4
Antenka 274 Posting Whiz

but this displaying column name as "length" and its values are numeric.How can solve this problem.

Here you can find the answers. There examples on VB, but good explanation of why that happens and how to solve it. Hope it will help you..

Can we add click event to rows of datagrid control.

This depends on why you need that. As one of the possible ways, you could catch DataGridView.CellMouseClick Event. And then locate the row, on which this cell placed.

Antenka 274 Posting Whiz

C# 3, .net 3.5

Antenka 274 Posting Whiz

:) Good luck.