Ver Mensaje Individual
  #4 (permalink)  
Antiguo 17/06/2009, 09:24
Betina232022
 
Fecha de Ingreso: enero-2008
Mensajes: 366
Antigüedad: 16 años, 4 meses
Puntos: 3
Respuesta: richtextbox.font.bold

Hola, perdón hasta hoy pude conectarme, ya puedo convertir el código en html a su respectivo formato para un richtextbox, les dejo la rutina por si la requieren.

public void Darformato()
{
int x, y = 3, In;
string cade = "", cad = "", cadfin = "", cadEsp;
bool R = false, B = false, I = false, S = false;

cade = RTB.Text;

RTB.Text = "";
for (x = 0; x < cade.Length; x++)
{
cad = cade.Substring(x, 1);

if (cad == "<")
{
cad = cade.Substring(x, y);

if (cad == "<b>")
{
B = true;
y = 3;
}
else
{
if (cad == "</b" || cad == "</b>")
{
B = false;
y = 4;
}
}
if (cad == "<i>")
{
I = true;
y = 3;
}
else
{
if (cad == "</i" || cad == "</i>")
{
I = false;
y = 4;
}
}
if (cad == "<a ")
{
S = true;
In = cade.IndexOf(">", x, cade.Length - x);
cadEsp = cade.Substring(x, (In + 1) - x);
y = cadEsp.Length;
}
else
{
if (cad == "</a" || cad == "</a>")
{
S = false;
y = 4;
}
}

x = x + y - 1;

}
else
{
y = 3;
cadfin = cadfin + cad;
RTB.AppendText(cadfin);
RTB.Select(RTB.Text.Length - 1, 1);
if (B == false && I == false && S == false)
{
y = 3;
R = true;

}
cambioStyle(R, B, I, S);
R = false;

cadfin = "";
}
}
}
public void cambioStyle(bool Re, bool Bn, bool It, bool Su)
{
if (Re == true)
{ style2 = FontStyle.Regular; }
if (Bn == true && It == true && Su == true)
{ style2 = FontStyle.Bold | FontStyle.Italic | FontStyle.Underline; }
if (Bn == true && It == false && Su == false)
{ style2 = FontStyle.Bold; }
if (It == true && Bn == false && Su == false)
{ style2 = FontStyle.Italic; }
if (Su == true && Bn == false && It == false)
{ style2 = FontStyle.Underline; }
if (Bn == true && It == true && Su == false)
{ style2 = FontStyle.Bold | FontStyle.Italic; }
if (Bn == true && Su == true && It == false)
{ style2 = FontStyle.Bold | FontStyle.Underline; }
if (It == true && Su == true && Bn == false)
{ style2 = FontStyle.Italic | FontStyle.Underline; }
RTB.SelectionFont = new Font(RTB.SelectionFont, style2);

}


saludos y que esten bien