Mitja Bonca 557 Nearly a Posting Maven

Hi, you can check it here.
And btw, if you figure it out, can you please share your working code with us?
thx in advance.

Mitja Bonca 557 Nearly a Posting Maven

Yes, "partial" keyword is missing.

Mitja Bonca 557 Nearly a Posting Maven

You are welcome.
If this is was helpful upVote, or if this was it, mark the thread as answered, so we close it.

Mitja Bonca 557 Nearly a Posting Maven

The code looks ok to me. What values do you have in origianl array?

Just one thing to clear it out:
If you have two arrays declared on the class level, then you do not need to use return and creating other arrays in methods inside of this class. Because those two array (original and finalyStore) are accessed in all the methods inside of the class.

So you can do:

public class AClass
{
    private float[] original = new float[5];
    private float[] finalyStore = new float[5];
 
    public AClass()
    {
        //init orginal
        original[0] = .....
        finalyStore = testToCopy();
    }
 
    private void testToCopy()
    {
        for(int i=0; i < original.length; i++)
        {
            finalyStore[i] = original[i];
        }
    }
}

But if you have set the code as this you dont even need an additional method (testToCopy). But maybe there is a bit different code you have (as you have stated).

Anyway, you code should work too. I dont know what might be wrong at all (it actually cannot be anything wrong).

Mitja Bonca 557 Nearly a Posting Maven

and btw, about math priorities, and using brackets:
multiplying has an advantage over dividing, so you do not need any bracket when you do:

A*B\C => this means A will be multiplied with B in the 1st place, then will be divided by C!
Mitja Bonca 557 Nearly a Posting Maven

I have explained how to set number of decimals. Have you read my post for above?

Math.Round(yourNumbe, numberOfDeciamls);
so:

textBox2.Text = Math.Round((dValue * _Units / _priceincur), 2)
Else
Mitja Bonca 557 Nearly a Posting Maven

No problem. You can mark the thread as answered now.
thx ina advance.

Mitja Bonca 557 Nearly a Posting Maven

i dont have any experience with datagridview so kindly express your solution in bit detail

hmmm, this will take some time then... ;)

Ok, regarding to your thread`s title, you want to pass data from textBox to DGV. You can do it this (Simple) way:

dataGrivView1[0,0].Value = txtbox1.Text; //0,0 is 1st column, 1st row
dataGrivView1[1,0].Value = txtbox1.Text; //1,0 is 2nd column, 1st row
dataGrivView1[2,0].Value = txtbox1.Text; //2,0 is 3rd column, 1st row

//for example if you want to pass data to 5th column and 10 row you do:
dataGrivView1[9,4].Value = txtbox1.Text;
Mitja Bonca 557 Nearly a Posting Maven

You are welcome.

Mitja Bonca 557 Nearly a Posting Maven

As said, use Math.Round method. 1st parameter in this method in the actual value you want to round, while 2nd parameter is the number of decimals.
If you will do as Luc001 showed, will do just fine or:

Dim dValue As Decimal = 0D
If Decimal.TryParse(textBox1.Text.Trim(), dValue) Then
	textBox2.Text = Math.Round((dValue * _Units / _priceincur), 4)
Else
	MessageBox.Show("Value is not decimal, please repair it.")
End If
Mitja Bonca 557 Nearly a Posting Maven

One of the possibilities is to use TextChanged event handler:

private void textBox1_TextChanged(object sender, EventArgs e)
        {
            string lastChar = textBox1.Text.Substring(textBox1.Lenght -1, 1);
            if(lastChar == " ")
            {
                 MessageBox.Show("User has just pressed spaceBar.");
            }            
        }

Or use can use KeyPress event, where you will get the last character of whitespace:

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
   if (!char.IsWhiteSpace(e.KeyChar))
   {
       MessageBox.Show("User has just pressed spaceBar.");
       //e.Handled = true;
   }
}
dotancohen commented: Thank you. +2
Mitja Bonca 557 Nearly a Posting Maven

Change this method to:

private void AddListBoxItem(object item)
       { 
           if (this.ConvBox.InvokeRequired)
               this.ConvBox.Invoke(new AddListBoxItemDelegate(AddListBoxitem), new object[] {item});
           else
               this.ConvBox.Items.Add(item);
       }
Mitja Bonca 557 Nearly a Posting Maven

Try it this way:

For i As Integer = 0 To ListBox1.Items.Count - 1
	Dim lstitem As String = ListBox1.SelectedItem.ToString()
	Dim sqlQuery As String = "UPDATE laitemtype SET IsActive = @active WHERE itemtypedescription=@lst"
	Dim cmd6 As New SqlCommand(sqlQuery, Con)
	'I hope oyu have created a new instance of SqlConnection AND Opened it!
	cmd6.Parameters.Add("@active", SqlDbType.Int).Value = 1
	cmd6.Parameters.Add("@lst", SqlDbType.VarChar, 144).Value = lstitem
	cmd6.ExecuteNonQuery()
Next
Mitja Bonca 557 Nearly a Posting Maven

You put create labels one beside another (lets say a few inches apart), and because you didnt disable AutoSize property, it means that the 1st label has Width size of 35 (35 is defualt), so your code only shows 1st letter A, other were hidden. Am I correct?

That is becuase your 2nd label (B letter) was hidden behind label of letter A.
My code has set the AutoSize to false, and set new width Size to 15. 15 is the width of a letter (and a bit more, so you dont have letters just one beside another).

Mitja Bonca 557 Nearly a Posting Maven

You are doing incorrect update statement. On the right side of the equl mark you have the parameter, which you then have to specify in the command, like:

var cmd = new OleDbCommand("UPDATE Resources SET Image= @a WHERE ResourceName= @b", conn);
     cmd.Parameters.Add("@a", OleDbType.VarChar).Value = listView.SelectedItems[0].Tag;
     cmd.Parameters.Add("@b", OleDbType.VarChar).Value = _username;
Mitja Bonca 557 Nearly a Posting Maven

This will do it:

public partial class Form1 : Form
    {
        Label[] lbls;
        public Form1()
        {
            InitializeComponent();

            char[] letters = Enumerable.Range('A', 'Z' - 'A' + 1).Select(i => (Char)i).ToArray();
            lbls = new Label[letters.Length];
            int x = 20;
            int y = 20;
            for (int i = 0; i < letters.Length; i++)
            {
                lbls[i] = new Label();
                lbls[i].Name = "label" + letters[i];
                lbls[i].Text = letters[i].ToString();
                lbls[i].Location = new Point(x, y);
                lbls[i].AutoSize = false;
                lbls[i].Size = new Size(15, 13);
                lbls[i].Cursor = Cursors.Hand;
                lbls[i].Click += new EventHandler(labels_Click);
                this.tabPage1.Controls.Add(lbls[i]);
                x += 16;
            }
        }

        private void labels_Click(object sender, EventArgs e)
        {
            Label lb = sender as Label;
            MessageBox.Show("You have clicked " + lb.Text);
        }
    }
Mitja Bonca 557 Nearly a Posting Maven

use SelectedItem property of comboBox:

comboBox1.Selecteditem.ToString();
Mitja Bonca 557 Nearly a Posting Maven

Hi, would you mind sharing the solution?
thx in advance.

Mitja Bonca 557 Nearly a Posting Maven

As i told you, you dont have to correct connection string. I cannot not do much about it here, since i dont know which database do you use.
For accurate connection string take a look at here.

Mitja Bonca 557 Nearly a Posting Maven

Can you access to the dataBase now, using SqlConnection class?

Mitja Bonca 557 Nearly a Posting Maven

I am glad I could help you.

Mitja Bonca 557 Nearly a Posting Maven

Maybe you have to change the Timer namespace to:

System.Windows.Forms.Timer timer1;

//when creating a new instance you do:
timer1 = new ystem.Windows.Forms.Timer();
Mitja Bonca 557 Nearly a Posting Maven

What you have to do is:
- put three buttons on the forms (do not chaange their namee, by defualt they will be names: button1, button2, button3)
- put a textBox
- and put a label over textBox

(so you only have to put 5 controls explained above).

Then you simple copy / paste the code I gave you. But be careful on th Form1 name. Form1 is by defaurt, if you change the project name when creating it, it will have different name.

Mitja Bonca 557 Nearly a Posting Maven
public partial class Form1 : Form
    {
        Timer timer1;
        Button[] btns;
        public Form1()
        {
            InitializeComponent();
            timer1 = new Timer();
            timer1.Interval = 1000;
            timer1.Tick += new EventHandler(timer1_Tick);
            timer1.Start();

            //create an array of buttons:
            btns = new Button[] { button1, button2, button3 };
        }

        protected override void OnShown(EventArgs e)
        {
            //set the button1 to be focused on the beginning:  
            button1.Focus();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            for (int i = 0; i < btns.Length; i++)
            {
                if (i.Equals(2))
                    timer1.Stop();
                else if (btns[i].Focused)
                {
                    btns[i + 1].Focus();
                    break;
                }                
            }
        }
    }
Mitja Bonca 557 Nearly a Posting Maven
Mitja Bonca 557 Nearly a Posting Maven

You dont need to use StringBuilder class as array. You can simple do:
REMEBER: before putting bytes into stirng, you will have to convert it, otherwise you will not get the correct result!!

private string Byte_To_Hex_Ar(Byte[] data) 
        {
            StringBuilder sb = new StringBuilder();
            foreach (byte b in data)
            { 
                sb.Append(b.ToString("X")); 
            }
            return sb.ToString();
        }

---------------------------
TO ADD:
If you will pass these data:

byte[] values = { 0x1, 0x2, 0x10, 0xFF };

string val = ByteArrayToString(values);

The returned string will be "1210FF"

This is how you do it.

Mitja Bonca 557 Nearly a Posting Maven

Use better see (or use) a doctor, if you are in troubles like you are now.

Mitja Bonca 557 Nearly a Posting Maven

You didnt set any varible to change it. You have to do it:

Curent_Year = Current_Year.AddDays(1); //on the end of the code!
Mitja Bonca 557 Nearly a Posting Maven

Exactly. In your particular case you do:

this.Controls.Add(TxBxArray[i]);
Mitja Bonca 557 Nearly a Posting Maven

Exactly. In your particular case you do:

this.Controls.Add(TxBxArray[i]);
Mitja Bonca 557 Nearly a Posting Maven

What error?
YOu have to tell me it.

Mitja Bonca 557 Nearly a Posting Maven

He is going to some Informatics school
He has no other obligations (but I mean real obligations, not some strange sport activity)
And he has no time for HIS school project which should be on 1st place of all orders.

Strange is this world today! But it sure wasn`t in my times (when I was back in the school).

NOTE: we are not here to support your laziness and doing your school/home work!
And $100 is not enough. I will do it for $500.
Take it or leave it :)

Mitja Bonca 557 Nearly a Posting Maven

Try to change it to:

con.ConnectionString = strconnection
If con.State = ConnectionState.Closed Then
	con.Open()
End If

Dim str As String = "Select CUSTOMERID from tbl_Customer"

cmd = New SqlCommand(str, objconnection)
Dim dr As SqlDataReader = cmd.Executereader()

While (dr.Read())
		'If the id column is not integer, chnage "int" with correct type (stirng I would say)!
	TXTCUSTOMERD.Text = CInt(dr("CUSTOMERID"))
End While

If String.IsNullOrEmpty(TXTCUSTOMERD.Text) Then
	TXTCUSTOMERD.Text = 0
	TXTCUSTOMERD.Text = Conversion.Val(TXTCUSTOMERD.Text) + 1
Else
	TXTCUSTOMERD.Text = Conversion.Val(TXTCUSTOMERD.Text) + 1
End If
dr.Close()
Mitja Bonca 557 Nearly a Posting Maven

Is maybe this what you have been looking for:

int[,] array = new int[2, 4] { { 1, 2, 3, 4 }, { 1, 2, 3, 4 } };
            List<int> list = new List<int>();
            for (int i = 0; i < array.GetLength(1); i++)
            {
                int sum = 0;
                for (int j = 0; j < array.GetLength(0); j++)
                {
                    sum += array[j, i];
                }
                list.Add(sum);
            }
            //list now has all sums of 2-d array!
            //result is: 2,4,6 and 8

If not, let me know.

Mitja Bonca 557 Nearly a Posting Maven

i need is if select 30days membership then expiry date to be generated from joining date with type of membership (i.e month,quartly,half-yearly,yearly)

Can you please say some more about this type of membership(month, quarty, half-yearly, yearly)? What are they suppose to meanm I mean what is their purpose in here?

Mitja Bonca 557 Nearly a Posting Maven

Oh, I see, I sure did miss it. Lately I wasnt around much. I can see there is a whole other thread for this issue. So I wont even interrupt.

Mitja Bonca 557 Nearly a Posting Maven
Mitja Bonca 557 Nearly a Posting Maven

Does your DataTable get filled up with data from dataBase?
Use a break point to "stop" the code, and then go with F11 key forward row by row, and with hovering mouse over some value (varible), you will see if there are data inside of it).

Mitja Bonca 557 Nearly a Posting Maven

YOu didnt start coding the correct way. You have to put buttons into an array, and loop through them and create a common event for them, like this:

//on form load on in constructor:
Button[] btns = new Buttons[]{button1, button2, button2, button4, button5, button6, button7, button8 };
foreach(Button btn in btns)
     btn.Click += new EventHanlder(buttons_Click);

private void buttons_Click(object sender, EventArgs e)
{
    Button button = sender as Button;
    //clicked button is not in "button" variable.
    //exmaple:
    string buttonName = button.Name;
    string butonText = button.Text;
    //you can now opperate wtih them..
}
Mitja Bonca 557 Nearly a Posting Maven

Delegates are used to add methods to events dynamically.
Threads run inside of processes, and allow you to run 2 or more tasks at once that share resources.

Another explanation:
Delegates: Basically, a delegate is a method to reference a method. It's like a pointer to a method which you can set it to different methods that match its signature and use it to pass the reference to that method around.

Thread is a sequentual stream of instructions that execute one after another to complete a computation. You can have different threads running simultaneously to accomplish a specific task. A thread runs on a single logical processor.

Mitja Bonca 557 Nearly a Posting Maven

Hi, try it this way:

public class testing
{
    delegate void mydelegate(string msg);
    public void btnStart_Click(object sender, EventArgs e)   // Click Event
    {          
         ThreadStart ts = new ThreadStart(StartServer);
         Thread t = new Thread(ts);           
         t.Start();
    }

    public void StartServer()
    {
   	 str = "Hello";
         function1(str);
    }
    public void function1(string str)
    {
        if(listBox1.InvokeRequired)
           listBo1x.Inkvoke(new mydelegate(function1), new object[] { str });
        else
           listBox1.Items.Add(str);
   }
}
Mitja Bonca 557 Nearly a Posting Maven

listView only shows strings, so if you want to convert those values form 2nd column to double they have to be double types, otherwise you will get that error.
Would you show me some more code to help you out?

Mitja Bonca 557 Nearly a Posting Maven

Oh OK. I'm not relieved after all :=( EditOnEnter lets me edit any of my columns and I don't want that. This is getting frustrating...

Sorry, I gave you the wrong code, it was for ComboBox column, sorry ones again.

What is your problem now? Can you please explain it a bit better?

Mitja Bonca 557 Nearly a Posting Maven

Try to use FolderBrowerDialog, to create or select directory:

public partial class Form1 : Form
    {
        string connString;
        string dirPath;
        public Form1()
        {
            InitializeComponent();            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog openFileDialog1 = new FolderBrowserDialog();
            // Show the FolderBrowserDialog.
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                dirPath = openFileDialog1.SelectedPath;
                connString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dirPath + "\\shell.mdb;Jet OLEDB:Engine Type=5";
                MessageBox.Show("This is the full connection string:\n" + connString);
            }
        }
    }

If I got your right, this is than it. Tell me what do you think.

Mitja Bonca 557 Nearly a Posting Maven

Hi, I didnt get you well.
You need to create a NEW folder some where on hdd to store your dataBase inside of it, Am I right?

Mitja Bonca 557 Nearly a Posting Maven

For forms which are opened for some small amout of time, like Login form, best way to close them (because they have to close sooner or later) is to use the "using" keyword and a ShowDialog() method:

//on your class from where you call login form:
using(LoginForm login = new LoginForm())
{
    if(login.ShowDialog() == DialogResult.OK)
    {
        //when login form will close the code will come in here
        //and login form will close it self!
    }
}

//on login form:
//when login validation is checked and validated (and validation is OK), you do:
this.DialogResult = DialogResult.OK;
//then the login form will close automatically when it will execute that code to the end!

This is how you do it.

Mitja Bonca 557 Nearly a Posting Maven

Hi,
1st you create a new instance of ListViewItem class.
Then you use this instance and a Text property (this one is for the 1st column).
If oyu want want to add other columns (subitems) you have to use instance property and SubItems.Add() method:

ListViewItem lvi = new ListViewItem();
lvi.Text = "1st column data";
lvi.SubItems.Add("2nd column data");
lvi.SubItems.Add("3nd column data");
//and so on...

//and add items and subItems to listView
listView1.Items.Add(lvi);

Instead of 1st two rows of code you can do:

ListViewItem lvi = new ListViewItem("1st column data"); //its the same
//you add item to the 1st item (that means to 1st column)

Hope this helps explaining how to add items to listView, and usig Items and SubItems.

Mitja Bonca 557 Nearly a Posting Maven

try changing the connect string of ConfigurationManager to:

string connect = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;

All the rest stays the same. If the connection string is correct, this has to work.

Mitja Bonca 557 Nearly a Posting Maven

We came to the misunderstandning here... I know for the cookie that is created in the local computer, and it has to be (and it is) used on that computer only.
As said, if you remember the password, some else can easily login to gmail from your computer - this is what Im saysing, not like you thing I was thniking: that if you type my userName in gmail, it will give you mine data - No. I was never ever thinking of this kind of approach.

Mitja Bonca 557 Nearly a Posting Maven

CellContentClicked is not suitable event to get comboBox clciked (or selected). You you will never get this code into work. Take a look my example, you have to use CheckBox_SelectedIndexChanged event, but since DGV does NOT have this kind of event, you have to do a work around, to use a "normal" comboBox event.

It works like charm :)