Antenka 274 Posting Whiz

Hello.
Isn't this non-stop recursive call to the same function:

public string GetClientsList()
        {
            try
            {
                Thread.Sleep(1000);
            }
            catch (Exception e1)
            {
                Console.writeline(e1.ToString());
            }
          return Program.ServerForm.GetClientsList();
        }
sknake commented: probably :P good catch +5
Antenka 274 Posting Whiz

You're welcome.
Good luck with your project :)

Antenka 274 Posting Whiz

Hehe .. you're welcome.

Please, mark this thread as "solved" if you got the answer on your question :)

Antenka 274 Posting Whiz

Hello, phantom8l.
This can be interesting for you: Manually painting a ToolStripSplitButton

Antenka 274 Posting Whiz

Hello, Darth Vader.

Just to make sure - is your code is a holistic part of code, which you execute or it's just necessary pieces to show to us...

I ask this because it's compiles and runs here perfectly, but with little correction: this part is taken into a method:

Dime2 Dim3 = new Dime2();

            for (int j = 0; j < 1000; j++)
            {
                Dim3.Add(new Dime1());

                for (int i = 0; i < 1000; i++)
                {
                    Dim3[j].Add("0");
                }
            }
Antenka 274 Posting Whiz

You're welcome :)

Antenka 274 Posting Whiz

Hello, phoenix_dwarf.

While playing with your code found interesting thingy: it works fine on every tab .. except the 1st one. Anyway, while trying to explain such behaviour, found this:

Note:
Focus is a low-level method intended primarily for custom control authors. Instead, application programmers should use the Select method or the ActiveControl property for child controls, or the Activate method for forms.

So, this should work fine:

tabControl1.SelectedIndex = 0;
txt_CLName.Select();
Geekitygeek commented: nice catch, i learnt something too here :p +1
Antenka 274 Posting Whiz

Thanks, guys :)
Hehe .. Spiritually Optimized .. interesting thingy :P

Antenka 274 Posting Whiz

You're welcome :)
Good luck with learning C#.

Please, mark this thread as solved if the issue is settled.

DdoubleD commented: Spiritually optimized....Awesome!--jk, good job! +4
Antenka 274 Posting Whiz

Hello.
Both ArrayList and List classes are provided to work with dynamic arrays. But, in ArrayList all elements have type of System.Object. And in List you specify the type of elements by yourself. Let's see what it gives to you:

1. Suppose, you have an array of strings.
For ArrayList: while adding new element to array - it will be
cast to an Object type and then added to list. Then to take the
value of it - you'd have to cast it back to String.

ArrayList list = new ArrayList();
            list.Add("String element");

            string element = (string)list[0];

For List: you're just define a List of strings and there's no need
in boxing/unboxing operations (casting to Object type and back).

List<string> otherList = new List<string>();
            otherList.Add("String element");
            string otherElement = otherList[0];

2. Since the every reference type can be cast to System.Object and every value type can be boxed into an Object, it's possible to have something like this (in ArrayList):

ArrayList list = new ArrayList();
            list.Add("String element");
            list.Add(2);

The List<T> is strong-typed, so it's one more advantage. E.g. it wouldn't allow you to add Integer in your list of Strings. You will be warned at compilation time that you're trying to do something illegal.

List<string> otherList = new List<string>();
            otherList.Add("String element");
            otherList.Add(2); // compilation time error

3. And here's a nice post, where performance of List And ArrayList was compared: ArrayList’s vs. generic List for primitive types and …

sknake commented: Great explanation +17
ddanbe commented: Nice and clear explanation :) +14
Antenka 274 Posting Whiz

uhm .. okies .. but not right now))

Antenka 274 Posting Whiz

Hehe .. well .. there's one more person, who scored 70 .. jasimp :)

Antenka 274 Posting Whiz

I just had no idea about that before taking this test .. lol
Probably should give a rest day to my modem and go for a walk :D

Antenka 274 Posting Whiz

Hello, DeOiD.
Here's one more way to go ..
If choose between Array, ArrayList or List<T> - I would suggest you use List<T>.
For keeping such values you can define a class or structure. For example:

public class Result
    {
        int rowNumber;
        string fieldName;
        string value;

        public Result(int rorNumber, string fieldNumber, string value)
        {
            // assign variables
        }
    }

if you have a few types of results, you can create more classes/structures ...

public class Result2
    {
        int rowNumber;
        string fieldName;
        string value;
        string whatever;

        public Result2(int rorNumber, string fieldNumber, string value, string whatever)
        {
            // assign variables
        }
    }

We know, that List can contain the elements of same type. So we should find the connection between 2 created classes:
1. Both classes (also as all reference types) are inherit from System.Object.
2. You can define the parent class for them by yourself.

What it will give to you? After that you can create a List:

List<object> resultSet = new List<object>();
.. or
List<SomeBaseClass> resultSet = new List<SomeBaseClass>();

and add elements to it:

resultSet.Add(new Result(1, "someName", "someValue"));
resultSet.Add(new Result2(1, "someName", "someValue", "something else"));

Depending on what way you'll choose - the new element of resultSet would be automatically converted to either Object or SomeBaseClass .

And then to determine, which type of result you currently working with - use is or as keywords.

sknake commented: good samples +17
DeOiD commented: really nice +3
Antenka 274 Posting Whiz

Hello, wil0022.
Indeed, you can't do like this:

if (final[0] & final[1] & final[2] & final[3] & final[4]  & final[5] & final[6] & final[7] & final[8] & final[9] != first[counter2])

I suppose this construction means "If first[counter2] isn't in the final array .."

If so - then the problem can be solved, e.g. by using nested loops:

// the number of distinct values found
            int numberOfDistinctNumbers = 0;

            // external loop will go through the entire First array
            // to check if the value already exist in the Final array
            for (int counter = 0; counter < ten; counter++)
            {
                // true - if the value of First[counter]
                // already exist in array
                bool alreayExist = false;

                // then we go through the Final array
                for (counter2 = 0; counter2 < numberOfDistinctNumbers; counter2++)
                {
                    // After the first occurrence of the value of First[counter]
                    // in the Final array - we setting the alreayExist to
                    // true and going out of that cycle
                    if (first[counter] == final[counter2])
                    {
                        alreayExist = true;
                        break;
                    }
                }

                // If we haven't found any occurrence of that number
                // in Final array - then it's distinct and we're adding it
                if (!alreayExist)
                {
                    final[numberOfDistinctNumbers] = first[counter];
                    numberOfDistinctNumbers++;
                }
            }
serkan sendur commented: turkish always support ukrainian +10
Antenka 274 Posting Whiz

Gosh .. 70. :$

Antenka 274 Posting Whiz

Hello.
I was playing with your code. Here's what I've got:

// selecting some text in RichTextBox
...
Clipboard.SetText(richTextBox1.SelectedRtf, TextDataFormat.Rtf);
sel.Paste();
Antenka 274 Posting Whiz

Hello, tiwas.
Split method has a few overloads. Take a look: String.Split Method

Instead of using ArrayList I would suggest you look at List<T>. It has a constructor, that can take a IEnumerable<T> as parameter, which is (in your case) the data, which Split method returns.

Antenka 274 Posting Whiz

Hello, Ichibang.

Some time ago I had similar weird problem. Take a look, maybe this can help you to solve yours: Problem updating Database using typed dataset

P.S. I suppose there's a better way to fix that. But I couldn't find it.

Antenka 274 Posting Whiz

Hello, S2009.

Beforehand little quotation from msdn:

CancelEventArgs..::.Cancel Property
Gets or sets a value indicating whether the event should be canceled.

Property Value
Type: System..::.Boolean
true if the event should be canceled; otherwise, false.

And now let's look at your code:

private void frmLibrary_FormClosing(object sender, FormClosingEventArgs e)
        {
            // there's no need in this line, because it's set to false by default
            e.Cancel = false;
            if (checkLogOff == false)
            {
                MessageBox.Show("Please Log Off before closing the Application");
                   // regarding to quote from msdn, you say: "Everything ok, keep closing"
                   e.Cancel = false;
                    // I'll talk about this one later.
                    this.ControlBox = false;
                    // unnecessary thing, because your method already finished it's job
                    return;
            }
            else
            {
                // Later ..
                this.ControlBox = true;
                // regarding to quote from msdn, you say: "Something goes wrong. Stop closing form"
                e.Cancel = true;
            }
        }

Ok, now few words about ControlBox. I suppose it would be more understandable for user if you will show/hide ControlBox in some other place. E.g. make it hidden when loading form and show it while logging off.

Also just a few thoughts in loud. I don't know if that's suited for your situation, but maybe you could ask user if he wants to log off and sign him off if he wants also and in formClosing event (insdead of showing/hiding ControlBox).

Antenka 274 Posting Whiz

Hello, EvilLinux.
At first - you should post your code in code tags.
About your code:
this should take current date and time

DateTime arrivaldate = DateTime.Now;

then troubles comes from here:

DateTime departuredate = DateTime.Parse("DateTime.Now");

to use Parse method with 1 string parameter, you should use something like this:

DateTime someDate = DateTime.Parse("15.09.09");

now about this one:

DateTime adddays = departuredate.AddDays(3);

Adds the specified number of days to the value of this instance.
Return Value
Type: System.DateTime
A DateTime whose value is the sum of the date and time represented by this instance and the number of days represented by value.

so, the result of AddDays is your departuredate.

Also to convert this date to string you can use either ToLongDateString(); or .ToLongTimeString(); methods.

Antenka 274 Posting Whiz

Hello.
Your trouble may lay here:

OleDbDataAdapter oleDbDA = new OleDbDataAdapter();

try to create your Data Adapter based on your connection:

OleDbDataAdapter oleDbDA = 
        new OleDbDataAdapter(selectCommand, connection);
Antenka 274 Posting Whiz

You're welcome.
You can also use foreach cycle:

foreach(string item in listBox1.SelectedItems)
{
    listBox2.Items.Add(item);
}
Antenka 274 Posting Whiz

Hello, you can iterate through selected items in your ListBox using ListBox.SelectedItems Property

Antenka 274 Posting Whiz

Hello, to generate Controls in runtime see the the threads, which were discussed not really much time ago here, on Daniweb:
C# Preforming Caluclations With Controls Created In Runtime
C# Cannot Read Dynamic Textbox

For using stored procedures:
The C# Station ADO.NET Tutorial: Using Stored Procedures

Antenka 274 Posting Whiz

Hi.
Well, at first - you don't change the "index" variable from the time, when it was created. You should specify the current index (since you're displaying not the first record of your array).

The second one - when your prog catch the proper event to process - you're changing only "index" value .. you also need to refresh your form.

Antenka 274 Posting Whiz

Yeah .. it also works fine here.

P.S. Are you sure, that your file, which lays in path has text in it (maybe this is that simple, that you're overlooking :P)?

Antenka 274 Posting Whiz

Hello.
You seem a bit enmeshed with variable names and Cotrol names.
E.g. let's take a look at TextBox creation:

TextBox textBox6 = new TextBox();
                textBox6.Location = new Point(260, 120);
                textBox6.Size = new Size(42, 20);
                this.Controls.Add(textBox6);

you have a variable named textBox6 , which keeps your newly created TextBox. The point is that you don't specify the TextBox's name and trying to find it using your variable name (which have neither part nor lot in TextBox name).

So, if you want to get this to work:

Controls.Find("textBox6", false);

then you should set the name of TextBox:

textBox6.Name = "textBox6";

For accessing dynamically created controls - you can look here:
C# Cannot Read Dynamic Textbox

Antenka 274 Posting Whiz

Using "array[number]" you're refer to 1 single element in array , which has a position number-1 (since the array indexes are starting from 0).
If you need to pass whole array - pass just the bookArray .

Antenka 274 Posting Whiz

You're welcome .. if your issue is solved - please mark this thread as solved :)

Antenka 274 Posting Whiz

As I understand correctly - you're trying to access dynamically created variable field2 outside the borders of it's visibility, rather than TextBox.

To locate your dynamically created TextBox you should use this:

this.Controls["textBox2"].Text = "I'm here";

or this:

//this method returns Control[], so you should specify the index
//of interested control in that array
this.Controls.Find("textBox2", false)[0].Text = "And here";
Antenka 274 Posting Whiz

Hello, as far as I understand - the tab pages and child forms are created in the runtime. So probably the solution can be something like this:

TabPage tabPage1 = new TabPage("ChildForm1");

            //you can use or pre-defined class for this, or just 
            //call upon Form class
            YourFormClass childForm1 = new YourFormClass();
            childForm1.TopLevel = false;
            childForm1.Visible = true;   

            //Also Anchor and Dock properties are the playground for
            //you to find the best arrangement       
            childForm1.Anchor = AnchorStyles.Bottom & AnchorStyles.Left & AnchorStyles.Right & AnchorStyles.Top;
            childForm1.Dock = DockStyle.Fill;
            childForm1.FormBorderStyle = FormBorderStyle.None;
            tabPage1.Controls.Add(childForm1);
            tabControl1.TabPages.Add(tabPage1);
Antenka 274 Posting Whiz

Sure .. here we go:
The Test class in this program represents your console window. It has some methods, but the one you're interested in is: cls().

What actually it does in the main method:
1. Creates an instance of console window
2. Prints some text in there
3. Waits for 5 seconds
4. Clears the window
5. Waiting for 5 seconds one more time
6. Exit

The waiting thing there ( Thread.sleep(5000); ) made only for demonstrative purposes.

Ask if you have any other questions :)

Antenka 274 Posting Whiz

The link, I gave you, contains the discussion, where your questions were explained .. also it gives one more example of clearing :)

Antenka 274 Posting Whiz

Hello, I haven't faced such problem before .. maybe this might help you:
Java Programming [Archive] - Clear screen?

Antenka 274 Posting Whiz

:) you're welcome

Antenka 274 Posting Whiz

How about use this:

arr[i+1][j]=sum;

instead of:

arr2[i+1][j-1]=sum;
Antenka 274 Posting Whiz

uhu .. what if you would use just "j" (considering that you're extracting 1 from "x" on your next steps):

arr2[i+1][x-1]=sum;
System.out.print(arr2[i+1][x-1]);
Antenka 274 Posting Whiz

Ok, good job.
But your code still remain tricky:

int arr[][]=new int[20][20];
int arr2[][]=new int[20][20];

Look, you missed the main thing of using 2 dimensional array. The point is: while you are moving through the first line of it - you're filling the 2nd line (of the same array .. so we can access it on the next loop iteration) to process on the next step.

Let's unwrap the code, you posted (in same manner):

//processing first line:
        int sum = a[0][0] + a[0][1];
        a2[1][0] = sum;

        sum = a[0][1] + a[0][2];
        a2[1][1] = sum;

        sum = a[0][2] + a[0][3];
        a2[1][2] = sum;
        
        sum = a[0][3] + a[0][4];
        a2[1][3] = sum;
//-------------------------------------------
//processing second line:
        sum = a[1][0] + a[1][1]; // point of attention
        a2[2][0] = sum;
//etc.

Here's what's in that point of attention: while we were processing the first line - we were adding results to the a2 array. And now, when we try to get the value of e.g. "a[1][0]" - we got zero, because in the a array only first row is filled with proper data (from users input).

Also I'm curious what are you trying to achieve here?

int x=j+1; // I mean, what for this "x" variable
    arr2[i+1][x-1]=sum;

P.S. That's not irritating at all. Everybody were starting from the beginning having same or similar troubles :P

Antenka 274 Posting Whiz

I can help (that's what I'm actually do) .. but the ready-made code won't make from you

an experienced coder

.. till you won't fully understand it.

If you interested - I can explain the jagged array for you. If you not interested in that - you still can use the regular array, like you did before.

Antenka 274 Posting Whiz

You won't program it correctly till you get the details of how it works. Let's unwrap the cycles. No indexes and such .. just the way, how it should go:
there's 2 things I've changed to make it more understandable:
- I took only the summing part
- And I divided it on 2 parts: summing and memorizing

//processing first line:
        int sum = a[0][0] + a[0][1];
        a[1][0] = sum;

        sum = a[0][1] + a[0][2];
        a[1][1] = sum;

        sum = a[0][2] + a[0][3];
        a[1][2] = sum;
        
        sum = a[0][3] + a[0][4];
        a[1][3] = sum;
//-------------------------------------------
//processing second line:
        sum = a[1][0] + a[1][1];
        a[2][0] = sum;

        sum = a[1][1] + a[1][2];
        a[2][1] = sum;

        sum = a[1][2] + a[1][3];
        a[2][2] = sum;
//-------------------------------------------
//processing third line:
        sum = a[2][0] + a[2][1];
        a[3][0] = sum;

        sum = a[2][1] + a[2][2];
        a[3][1] = sum;
//-------------------------------------------
//processing fourth line:
        sum = a[3][0] + a[3][1];
        a[4][0] = sum;

That's what it actually supposed to do. Now all you have to to is wrap it back to short form with cycles. To do that you should mark out the dependencies in index changing. Here's some points of attention to you:
1. As adatapost suggested - you can use Jagged array. Because each next row in your array is less that previous by 1. Look closer on a example given by adatapost .. and more closer to the place, where each row is created.
2. Since that - there's no …

Antenka 274 Posting Whiz
kvprajapati commented: Well said. +7
Antenka 274 Posting Whiz

Hey, akulkarni.
There're some logic errors:
1.

for(j=5;j>0;j--)
{
i=0;
while(i<5)
{
int c=arr[i][j]+arr[i][j-1];
System.out.print(c);
i++;
}
System.out.println();
}

Just look what happening e.g. on the first step of your for-cycle:
1. j=5; i=0; you're taking elements with coordinates (row=0; column=5) and (row=0; column=4) .. and returning sum of them to the c variable. Print it and increase i.
j=5; i=1; you're taking elements with coordinates (row=1; column=5) and (row=1; column=4) ..
.. and so on..
What we have - you're moving through column .. but you supposed to go through rows.

Also there's one more trouble: when you count and output your sum - you don't memorize that number (for use in the next iteration of a cycle) .. so you have no work to do for the next step of your for-cycle.

Antenka 274 Posting Whiz

Hello.
This might be helpful for you: Export GridView To Word/Excel/PDF/CSV in ASP.Net

Antenka 274 Posting Whiz

Hello, pt0909.
To compare values you should use "==".

if (RBl1.SelectedValue == "A")

.

Also the property of the label, which you trying to access here:

mesg.text

should start with the capital letter:

mesg.Text

C# is case-sensitive.

Antenka 274 Posting Whiz

Hello.
There're a few ways to create dll in C#:
1. You can use only compiler ("csc.exe"). How to: Create and Use C# DLLs (C# Programming Guide).
2. Or you can use the abilities or your IDE (e.g. here is an example of creating it in VS 2005) Create DLL with C# (C-sharp).

Antenka 274 Posting Whiz

Well, then I have no idea .. O.o
I get same exception ("Object reference not set to an instance of an object.") when after this:

object valor = rk.GetValue(KeyName);

the value remains 'null'. And after trying to cast it to String here:

if (valor.ToString() == "")

I get this exception.

Antenka 274 Posting Whiz

Ok, if I understand you correctly, you need to write to the JList the messages, recieved from server (for client). Step by step, using given example:
1. Create model

DefaultListModel saveList = new DefaultListModel();

(in your code, you use ListModel. It's abstract class and you can't create an instance of it. So I took for this DefaultListModel (as you do in server side))

2. Create your JList basing on this model:

save = new JList(saveList);

(you already do this)

3. Take the message from server and then pass it to your model:

message = (String) input.readObject();
saveList.addElement(message);
Antenka 274 Posting Whiz

Hello, jen140.
If I understand you correctly, here:

if (valor.ToString() == "")

you're check if the operation rk.GetValue(KeyName); returned nothing to the 'valor' variable. Try to change it on this:

if (valor == null)
Antenka 274 Posting Whiz

All this (working with JList using model) you have in your server code.