1

this question might be very basic. But I just want to make this clear:

lets say I have a code like :

string currentToner = (string)((Hashtable)ht[1])["value"];
string maxToner = (string)((Hashtable)ht[2])["value"];

Now I want to set this value in data grid view.

int number = dataGridView1.Rows.Add();
dataGridView1.Rows[number].Cells[0].Value = currentToner."/".maxToner;  //-->this is not the correct way.

How to set the value so that it looks something like:

5000/10000
1
  • dataGridView1.Rows[number].Cells[0].Value = currentToner + "/" + maxToner;
    – Rick S
    Jun 2, 2014 at 1:36

2 Answers 2

1

You are doing it the PHP way, in C# string concatenation is done with plus signs

dataGridView1.Rows[number].Cells[0].Value = currentToner + "/" + maxToner; 

You can format the string as well

dataGridView1.Rows[number].Cells[0].Value = string.Format("{0}/{1}", currentToner, maxToner); 
1

If you want to display a string, set a string as the value :

dataGridView1.Rows[number].Cells[0].Value = currentToner + "/" + maxToner;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.