i want to display the text in rows how can i do this here is the code which does that
text=messages+"";
Please change this line of code:
szText = szText + szMessage + "\r<br>";
To this:
szText += szMessage;
Related
I have a following code:
DataSourceSelectArguments sr = new DataSourceSelectArguments();
DataView dv = DurationSQL.Select(sr) as DataView;
if (dv.Count != 0)
{
GridView2.Rows[0].Cells[0].Text = "Duration: \r" + dv[0][0].ToString() + "\r|";
}
I would like to make the static text:
Duration:
Displayed in bold while the rest of the text has no styling applied any way to achieve this?
You can put HTML into the cell text to achieve this, while at the same time preventing that HTML from being HtmlEncoded, like this:
Put HTML into the cell:
GridView2.Rows[0].Cells[0].Text = "<b>Duration:</b><br />"
+ HttpUtility.HtmlEncode(dv[0][0].ToString()) + "<br />|";
I included a call to .HtmlEncode(), but if the value is e.g. a number you may even skip that.
Prevent HTML from being encoded (use it for your first column, based on the fact that you use Cells[0]):
<asp:BoundField DataField="YourColumn" HtmlEncode="False" />
string text = GridView1.Rows[0].Cells[0].Text;
var span1 = new HtmlGenericControl("span");
span1.InnerHtml = "<strong>Duration:</strong> \r" + text;
GridView2.Rows[0].Cells[0].Text = span1.InnerHtml;
Seemed to work thanks for the comment
I'm trying to replace a certain line in a .txt file when I click the Update Button
This is what my program looks like
http://i.imgur.com/HKu4bGo.png
This is my code so far
string[] arrLine = File.ReadAllLines("Z:/Daniel/SortedAccounts.txt");
arrLine[accountComboBox.SelectedIndex] = "#1#" + firstNameInfoBox.Text + "#2#" + lastNameInfoBox.Text + "#3#" + emailInfoBox.Text + "#4#" + phoneNumberInfoBox.Text + "#5#EMAIL#6#";
File.WriteAllLines("Z:/Daniel/SortedAccounts.txt", arrLine);
This is what's inside SortedAccounts.txt
#1#Bob#2#Smith#3#Bob#Smith.com#4#5551234567#5#EMAIL#6#
#1#Dan#2#Lastyy#3#Daniel#Lastyy.com#4#5551234567#5#EMAIL#6#
The ComboBox is in the order as the Txt File.
So I get the same Index as the selected item in the ComboBox. And then I want to delete that line and then add a new line that same txt file with the updated information.
My code isn't doing this for some reason though and I can't figure it out
Try this out using List to easily remove an entry at a certain index. Don't forget to reload the combobox data source when the file is updated to avoid index mismatch etc..
List<string> arrLine = File.ReadAllLines("Z:/Daniel/SortedAccounts.txt").ToList();
arrLine.RemoveAt(accountComboBox.SelectedIndex);
string newLine = "#1#" + firstNameInfoBox.Text + "#2#" + lastNameInfoBox.Text + "#3#" + emailInfoBox.Text + "#4#" + phoneNumberInfoBox.Text + "#5#EMAIL#6#";
arrLine.Add(newLine);
File.WriteAllLines("Z:/Daniel/SortedAccounts.txt", arrLine);
I'm working on a project now, to make it easier to work I decided to make related textbox, the question is how to set the value of textbox so that it will be appears automatically?
Inthis case, Rnol = Pnol + Qnol + Nnol
I want Rnol value to be printed automatically in tbRnol/textbox Rnol when I click Button..
Pnol = double.Parse(tbPnol.Text);
Qnol = double.Parse(tbQnol.Text);
Nnol = double.Parse(tbNnol.Text);
Rnol = Pnol + Qnol + Nnol(tbRnol.Text); //I've try this but it clearly wrong syntax
You could modify your last line to:
Rnol = Pnol + Qnol + Nnol;
And add this one:
tbRnol.Text = Rnol.ToString();
code
while (dr.Read())
{
string s = dr["Title"].ToString() + Environment.NewLine + dr["Description"].ToString();
row["Title"]= s.Trim();
dt.Rows.Add(row["Title"]);
}
i want to break the line in my datagridview.i have row value with "name subject",i want to split it as "name"(newline)"subject" in the same row itself.
Is the problem that line returns are not being displayed in cells in your DataGridView?
If so you need to set the DataGridViewCellStyle.WrapMode Property of the Column you want to see line returns on to DataGridViewTriState.True.
After you do that the Cells in that column will display line breaks within a cell using Environment.NewLine, \n, etc.
You need to set someColumn.DefaultCellStyle.WrapMode = DataGridViewTriState.True; on whatever column you want for it to display multiple lines in.
did you try using: dt.Rows.Add(row["Title"].ToString().Replace(" ", "\r\n"));
I need to know the command that I can print a sentence like "the item Peter at row 233 and column 1222 is not a number " .
I far as now I have made this:
string[] lineItems = (string[])List[]
if (!Regex.IsMatch(lineItems[0], (#"^\d*$")))
textBox2.Text += " The number ,lineItems[0], is bigger than
10 " + Environment.NewLine;
I want to print the array fields that have error. So if it finds something it will print it.
I made a code that correctly prints that there is an error on this line of the array, but I cant print the item of the array.
I need to have an Environment.NewLine because I will print many lines.
Thanks ,
George.
foreach (int lineNumber in lineItems)
{
if (lineNumber > 10)
textBox2.Text += "The number " + lineNumber + " is bigger than 10\n";
}
Something like this should work, (I have not checked the c# code, I am working on a mac at the moment)
TextBox2.Text="This is FirstLine\nThis is Second Line";
The code is not compilable absolutely, but I may be understand what you're asking about.
If you are asking about how to compose the string of text box, by adding new strings to it, based on some desicional condition (regex), you can do folowing, pseudocode:
StringBuilder sb = new StringBuidler();
if (!Regex.IsMatch(lineItems[i], (#"^\d*$")))
sb.Append(string.Format(The number ,{0}, is bigger than 10, lineItems[i]) + Environment.NewLine);
textBox2.Text = sb.ToString();
If this is not what you want, just leave the comment, cause it's not very clear from post.
Regards.