I'm making an application and i need get the same interval of space from a line in many items (strings). My code is something like that
p = "";
int contaletras = 0;
int maxPalavra = 14; int xpto;
contaletras = item.Length;
xpto = maxPalavra - contaletras;
for (int i = 0; i < xpto; i++)
{
p = p + " ";
}
StringBuilder m = new StringBuilder();
m.Append(item);
m.Insert(item.Length, p);
RTB_Exames.Text = RTB_Exames.Text + m.ToString() + " ";
So, my item.length is all the time 14 characteres. But
i dont know why i have this result when in textvisualizer in c# i have this. I will show some image in this link:
https://drive.google.com/file/d/0B5tH_Qo3-GvhSEJrOXVsTzhIQVk/edit?usp=sharing
https://drive.google.com/file/d/0B5tH_Qo3-GvhaTN5WUM1M2M3QVU/edit?usp=sharing
You can either set the font in the visual editor for the TextBox control or set it via:
RTB_Exames.FontFamily = new FontFamily("Consolas");
Related
I'm drawing text to a RenderForm in SharpDX using:
string s = "";
for (int i = 0; i < log.Count; i++)
s += log[i] + "\n";
renderView.DrawText(s, textFormat, logBoundsRect, brush, DrawTextOptions.Clip);
However eventually the log list becomes long enough for the text to overflow. How do I detect this overflow so that I can adjust how much of my log list is drawn accordingly?
I figured out how to do it thanks to #Simon Mourier's comment.
string s = "";
TextLayout tl;
while (true) {
s = "";
for (int i = logPosition; i < log.Count; i++) {
s += log[i];
if (i + 1 < log.Count)
s += "\n";
}
tl = new TextLayout(factory, s, textformat, logBoundsRect.Width, logBoundsRect.Height);
if (!(tl.Metrics.Height > logBoundsRect.Height))
break;
logPosition++;
tl.Dispose();
};
renderView.DrawTextLayout(logBoundsRect.TopLeft, tl, brush);
tl.Dispose();
logPosition is a global int that keeps track of where in the list to start reading from.
I am trying to get a clickable file path using asp.net c# visual studios web form, meaning to say that it is like windows file explorer, allowing the person to navigate through the different levels of folders etc, can anyone provide any links to help get me started? [1]: https://i.stack.imgur.com/WyyLq.png
You could try to get the path string and divide it in multiple pieces. Then store them in multiple textboxes, labels, buttons or whatever you want. My form looks like this: Picture Form
Secondly, you will have to update those (in my case) textboxes to save the path. See my code and decide what you want to use, and if you have to modify it.
private void changePath()
{
String path = webBrowser1.Url.AbsolutePath;
if (path.Contains(#"/")) { path = path.Replace(#"/", #"\"); }
string[] directories = path.Split(Path.DirectorySeparatorChar);
int count = directories.Count();
if (count <= 6)
{
textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = "";
for (int i = 0; i < count; i++)
{
String txt = "textBox" + (i + 1);
TextBox tbx = this.Controls.Find(txt, true).FirstOrDefault() as TextBox;
tbx.Text = directories[i];
}
}
else
{
int p = count / 6;
int z = count - (p * 6);
for (int i = 0; i < count; i++)
{
int g = i - 1;
String txt = "textBox" + (i + 1);
TextBox tbx = this.Controls.Find(txt, true).FirstOrDefault() as TextBox;
tbx.Text = directories[z];
z++;
if (i == 5)
{
break;
}
}
}
}
Second step is to make click functions on the (in my case) textboxes. Here is one sample of how you can do this. See for yourself what you can do.
private void textBox5_Click(object sender, EventArgs e)
{
if(!textBox5.Text.Equals(String.Empty))
{
String p = webBrowser1.Url.AbsolutePath;
if(!textBox6.Text.Equals(String.Empty))
{
webBrowser1.Url = new Uri(p.Replace(#"/" + textBox6.Text, ""));
}
}
}
This code will remove the last piece, leaving you with a new path. Example:
Before: C:\Users\USERNAME\Desktop\C#
After:
After: C:\Users\USERNAME\Desktop
Again, you have to look what works for you. There are multiple ways to resolve your issue.
Good Luck!
Twan.
I made a loop:
for (int i = 0; i < sumUSERS; i++ )
{
principal.UserPrincipalName = "bn" + txtbox_cusnumber.Text + "." + txt_user1.Text;
}
In my Form i have Text boxes with the following names :
txt_user1
txt_user2
txt_user3
How can I set the value i in txt_user(i).text?
I hope my question is understandable.
Make an array of the boxes, and use an index, like this:
var txt_user = new [] {txt_user1, txt_user2, txt_user3};
for (int i = 0; i < txt_user.Length ; i++ ) {
principal.UserPrincipalName += "bn" + txtbox_cusnumber.Text + "." + txt_user[i].Text;
}
Note that I replaced = with +=, otherwise the text would be the same as if you used txt_user3 by itself (i.e. only the last assignment would stay).
I want to automatically add parameters based on the input of control numbers.
the following code will give me sp_INSERT #COL5, sp_INSERT #COL4, so on...
control = 5;
while(1<=control)
column = '#COL'
string setValues = "sp_INSERT'" + column + control + "';"
control = control - 1;
What I want to achieve is sp_INSERT #COL5, #COL4, #COL3, so on...
Just... loop?
int control = 5;
string colPrefix = "#COL";
var sql = new StringBuilder("sp_INSERT ").Append(colPrefix).Append(control);
// note first item has different format due to comma
for(int i = control - 1; i > 0; i--)
{
sql.Append(", ").Append(colPrefix).Append(i);
}
sql.Append(';');
string s = sql.ToString();
Simple loop, not a complete solution, but it might help...
string myString = "INSERT ";
for (int i = 5; i > 0; i--)
myString = string.Format("{0} #COL{1}, ", myString, i);
Hello I have a DataList that has four lables and they all end with a number 1-4. In my code behind I have a for loop and an array that I want to set the labels of the Datalist with.
for (int x = 0; x< cartreciept.Items.Count; x++)
{
DataListItem item = cartreceipt.Items[x];
string catalogtype = ("select CatalogType From SC Where OrNum=" + OrNum)
if (catalogtype="TC")
{
((Panel)item.FindControl("pnlIprintInfo")).Visible = true;
string scRID = ("Select SCRID From SC Where OrNum =" + OrNum
for(int y = 1; y<5; y++)
{
string lT[y] = (Select LineText From table Where SCartRD =" + scRID + " AND LN=" + y)
((Label)item.FindControl("lbl[y]")).text = lT[y];
}
}
}
So would the ((Label)item.FindControl("lbl[y]")) work? most of this code is just pseudo code until I figure the details out. If you need to know anything else I can provide what needs to be known, I am open to other suggestions as well. Thank you to any one who can offer some help.
You can use this code - based on string.Format("....{0}",arguments)
var control = (Label)item.FindControl(string.Format("lbl{0}",y));
I suggest you to use DataList.ItemDataBound
Link : http://msdn.microsoft.com/fr-fr/library/system.web.ui.webcontrols.datalist.itemdatabound.aspx