Foros del Web » Programación para mayores de 30 ;) » .NET »

FAQ´S del foro de Net

Estas en el tema de FAQ´S del foro de Net en el foro de .NET en Foros del Web. Pregunta :Compactar BBDD MySQL desde vb.net Respuesta: Tenemos que meter en la base de datos una tabla con todos los nombres de las tablas de ...

  #91 (permalink)  
Antiguo 27/10/2005, 08:58
 
Fecha de Ingreso: agosto-2004
Mensajes: 234
Antigüedad: 19 años, 8 meses
Puntos: 1
Compactar BBDD MySQL desde vb.net

Pregunta :Compactar BBDD MySQL desde vb.net

Respuesta:

Tenemos que meter en la base de datos una tabla con todos los nombres de las tablas de nuestra base de datos y luego atraves de un MySqlDataReader tendremos que capturar dichos nombres para formar la cadena de OPTIMIZACION la cual se la pasaremos mediante un Comando.Aqui les dejo un codigo de prueba,espero que les sea util.


Cita:
Dim cadena As String

Me.mysqlconnection1.ConnectionString = "Definimos nuestra cadena Conexion"

mysqlconnection1.Open()
Dim miComando1 As New MySqlCommand("SELECT tabla FROM tablas_bd", mysqlconnection1)

Try
mysqlconnection1.Open()
Dim miReader As MySqlDataReader = miComando1.ExecuteReader()

While miReader.Read()

If cadena = "" Then
cadena = miReader.GetString(0).ToString
Else
cadena = cadena & "," & miReader.GetString(0).ToString
End If

End While

Dim miComando2 As New MySqlCommand("OPTIMIZE TABLE " & cadena, mysqlconnection1)
miComando2.ExecuteReader()
MsgBox("La Optimización ha concluido con éxito.", MsgBoxStyle.Information, "e-Traza")

Catch ex As Exception
MsgBox("La Optimización no ha podido llevarse acabo." & Chr(13) & "Ha habido un error de conexión.", MsgBoxStyle.Exclamation, "e-Traza")

Finally

mysqlconnection1.Close()

End Try
  #92 (permalink)  
Antiguo 29/10/2005, 17:44
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema:Tips and Trick (web app)
Pregunta: Como insertar un archivo .swf (flash) a mi página
Respuesta:
http://www.forosdelweb.com/showthrea...ash#post795231

Y si quieres crear un control:
http://www.codeproject.com/aspnet/As...vieControl.asp

Última edición por RootK; 24/03/2006 a las 09:29
  #93 (permalink)  
Antiguo 23/12/2005, 17:44
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Windows Forms
Pregunta: Como transformar a icono un BMP
Respuesta:
http://www.forosdelweb.com/f29/vb-net-pasar-ico-desde-imagelist-358477/
__________________
Nadie roba nada ya que en la vida todo se paga . . .

Exentrit - Soluciones SharePoint & Net
  #94 (permalink)  
Antiguo 26/12/2005, 02:45
Avatar de X.Cyclop
Usuario baneado!
 
Fecha de Ingreso: diciembre-2005
Ubicación: México, D.F.
Mensajes: 1.328
Antigüedad: 18 años, 4 meses
Puntos: 0
Información

Tema: Manuales
Pregunnta: Dónde encuentro más manuales de Asp.Net?
Respuesta:
http://www.microsoft.com/argentina/m...cion/intro.asp
http://www.entraenlared.com/asp/
http://www.asp.net/Tutorials/quickstart.aspx [inglés]
  #95 (permalink)  
Antiguo 29/12/2005, 13:36
Avatar de rodri  
Fecha de Ingreso: febrero-2005
Mensajes: 406
Antigüedad: 19 años, 2 meses
Puntos: 2
Libros

Tema: .NET y otros
Pregunta: donde consigo un sitio para bajar libros de .net?
Respuesta: www.flazx.com

Este es uno de los mejores sitios que vi donde te puedes bajar libros, solo utiliza el buscador y pon ".net" salen mas de cien libros.
__________________
0.o Rodri
  #96 (permalink)  
Antiguo 06/01/2006, 09:55
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Windows Forms
Pregunta: Como colapsar un panel
Respuesta:
http://www.codeproject.com/vb/net/Co...blePanelVB.asp
__________________
Nadie roba nada ya que en la vida todo se paga . . .

Exentrit - Soluciones SharePoint & Net
  #97 (permalink)  
Antiguo 06/01/2006, 09:57
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Windows Forms
Pregunta: Como autocompletar un combo
Respuesta:
http://www.codeproject.com/vb/net/au...e_combobox.asp
__________________
Nadie roba nada ya que en la vida todo se paga . . .

Exentrit - Soluciones SharePoint & Net
  #98 (permalink)  
Antiguo 10/01/2006, 09:28
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: General
Pregunta: Donde encontrar ejemplos de open source y/o recursos
Respuesta:
http://www.forosdelweb.com/f29/open-source-net-362268/
  #99 (permalink)  
Antiguo 11/01/2006, 11:56
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Web App
Pregunta:
Que son los archivos resx ?
Respuesta:
Los archivos resx consisten en entradas XML para especificar los objetos y las cadenas dentro de los tags del XML
Para mayor referencia :
http://msdn.microsoft.com/library/de...FileFormat.asp
  #100 (permalink)  
Antiguo 11/01/2006, 12:00
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: General (web app)
Pregunta: Como obtengo la URL de la página sin los querystings
Respuesta:

vb.net
Cita:
Dim stringUri As String = "http://www.pagina.com/?id=1&auid=16"
Dim weburi As Uri = New Uri(stringUri)
Dim query As String = weburi.Query
Dim weburl As String = stringUri.Substring(0, stringUri.Length - query.Length)
Response.Write(weburl)
c#
Cita:
string stringUri = "http://www.pagina.com/?id=1&auid=16";
Uri weburi = new Uri(stringUri);
string query = weburi.Query;
string weburl = stringUri.Substring(0, stringUri.Length - query.Length);
Response.Write (weburl);
  #101 (permalink)  
Antiguo 11/01/2006, 12:34
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Web App
Pregunta: Como guarar en un archivo HTML el resultado de una página aspx.
Respuesta:

vb.net
Cita:
Dim mywebReq As WebRequest
Dim mywebResp As WebResponse
Dim sr As StreamReader
Dim strHTML As String
Dim sw As StreamWriter
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mywebReq = WebRequest.Create("http://localhost/pagina.aspx")
mywebResp = mywebReq.GetResponse()
sr = New StreamReader(mywebResp.GetResponseStream)
strHTML = sr.ReadToEnd
sw = File.CreateText(Server.MapPath("temp.html"))
sw.WriteLine(strHTML)
sw.Close()
Response.WriteFile(Server.MapPath("temp.html"))
End Sub
c#
Cita:
WebRequest mywebReq ;
WebResponse mywebResp ;
StreamReader sr ;
string strHTML ;
StreamWriter sw;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
mywebReq = WebRequest.Create("http://localhost/pagina.aspx");
mywebResp = mywebReq.GetResponse();
sr = new StreamReader(mywebResp.GetResponseStream());
strHTML = sr.ReadToEnd();
sw = File.CreateText(Server.MapPath("temp.html"));
sw.WriteLine(strHTML);
sw.Close();
Response.WriteFile(Server.MapPath("temp.html"));
}
  #102 (permalink)  
Antiguo 11/01/2006, 12:41
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Tips and Tricks (web app)
Pregunta: Como convertir un Color a su equivalente en Hexadecimal ?
Respuesta:

vb.net
Cita:
Function ToHexColor(ByVal c As Color) As String
Return "#" + c.ToArgb().ToString("x").Substring(2)
End Function
c#
Cita:
string ToHexColor(Color c )
{
return "#" + c.ToArgb().ToString("x").Substring(2);
}
Y para llamarlo :

Response.Write(ToHexColor(Color.Blue))
  #103 (permalink)  
Antiguo 17/01/2006, 18:20
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Windows Forms
Pregunta: Como puedo hacer para que mis controles tomen el mismo tamaño que mi ventana cuando la maximizo o la ajusto a un determinado tamaño
Respuesta: Todos los controles tienen la propiedad "Anchor" donde indicas si quieres que se ajuste al tamaño a la izquierda, derecha o en todos los sentidos

http://msdn2.microsoft.com/en-us/lib...ol.anchor.aspx
  #104 (permalink)  
Antiguo 27/01/2006, 10:25
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Web Forms (tips and tricks)
Pregunta: Como hacer que me despliegue un texto sugerido (empleando ajax)
Respuesta:
http://www.codeproject.com/aspnet/ad...glesuggest.asp
  #105 (permalink)  
Antiguo 14/03/2006, 10:34
 
Fecha de Ingreso: octubre-2000
Mensajes: 1.692
Antigüedad: 23 años, 6 meses
Puntos: 19
Tema: Web Forms (IIS)
Pregunta: Failed to access IIS metabase
Respuesta:

Aveces un error molesto es el que se puede recibir si usas tu IIS para ejecutar páginas ASP.NET:

"Failed to access IIS metabase "

Este problema te lo puede dar si instalar el IIS teniendo instalado el frameworks o el visual estudio.

Para solucionarlo puedes probar primero ir a panel de control, agregar o quitar programar y reparar frameworks y reiniciar XP.
Con esto se tendría que solucionar el problemita. De seguir el problemita, puedes probar desinstalar el Frameworks y reinstalarlo.
__________________
PD: Con amor, fe, amor a Dios y amistad podemos hacer un mundo mejor!!!!
  #106 (permalink)  
Antiguo 15/03/2006, 17:16
Avatar de pempas  
Fecha de Ingreso: diciembre-2003
Ubicación: Barcelona
Mensajes: 985
Antigüedad: 20 años, 4 meses
Puntos: 6
Tema: Redimensionar imágenes
Pregunta: ¿Cómo redimensionar imágenes al vuelo?
Respuesta: Para redimensionar imágenes al vuelo hay que crear una página VB.Net y escribir el siguiente código:

Código:
' Initialize objects
Dim objImage, objThumbnail As System.Drawing.Image
Dim strServerPath, strFilename As String
Dim shtWidth, shtHeight, MaxHeight, Coefficient, W, H As Short 
    
' Get image folder path on server - use "\" string if root
strServerPath = Request.ServerVariables("APPL_PHYSICAL_PATH") & "img\"
' Retrieve name of file to resize from query string
strFilename = strServerPath & Request.QueryString("filename")
' Retrieve file, or error.gif if not available
Try
    objImage = objImage.FromFile(strFilename)
Catch
    objImage = objImage.FromFile(strServerPath & "no.jpg")
End Try
' Retrieve width from query string
If Request.QueryString("width") = Nothing Then
    shtWidth = objImage.Width
ElseIf Request.QueryString("width") < 1 Then
    shtWidth = 100
Else
    shtWidth = Request.QueryString("width")
	W = Request.QueryString("width")
End If

'Ahora miramos que no sobrepase el máximo de alto.
If Request.QueryString("Height")<>Nothing Then
	MaxHeight = Request.QueryString("Height")
	If  objImage.Width > shtWidth Then
		shtWidth = objImage.Width / (objImage.Height / MaxHeight)
		shtHeight = objImage.Height / (objImage.Width / shtWidth)
		If shtWidth > W Then
			H = shtHeight
			shtHeight = MaxHeight / (shtWidth / W)
			shtWidth = W / (H / MaxHeight)
		End If
	Else
		shtWidth = objImage.Width
		shtHeight = objImage.Height
	End If
Else
	' Work out a proportionate height from width
	If  objImage.Width > shtWidth Then
		shtHeight = objImage.Height / (objImage.Width / shtWidth)
	Else
		shtWidth = objImage.Width
		shtHeight = objImage.Height
	End If
End If

' Create thumbnail
objThumbnail = objImage.GetThumbnailImage(shtWidth, _
  shtHeight, Nothing, System.IntPtr.Zero)
' Send down to client
Response.ContentType = "image/jpeg"
objThumbnail.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
' Tidy up
objImage.Dispose()
objThumbnail.Dispose()
¿Cómo hacemos la llamada a la imagen?:
Para hacer la llamada la realizamos así:

resize.aspx?filename=imagen.jpg&width=640&Height=4 80

Extraído de http://www.developer.com/net/asp/article.php/3098311

Ahora si alguien se anima e indica como incluir una marca de agua a este código ya sería lo mejor...

Última edición por RootK; 24/03/2006 a las 09:58
  #107 (permalink)  
Antiguo 27/03/2006, 10:09
 
Fecha de Ingreso: octubre-2000
Mensajes: 1.692
Antigüedad: 23 años, 6 meses
Puntos: 19
Tema: Web Forms
Pregunta: Tutoriales
Restpuesta:
Desde esta dirección podes bajar varios videos para aprender ASP.NET:

http://msdn.microsoft.com/asp.net/le...t/default.aspx

Están en ingles.
__________________
PD: Con amor, fe, amor a Dios y amistad podemos hacer un mundo mejor!!!!
  #108 (permalink)  
Antiguo 11/04/2006, 16:44
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Web App
Pregunta: Como hacer que mi textbox solo acepte números
Respuesta:
http://www.forosdelweb.com/f29/validacion-campos-numericos-385162/
__________________
Nadie roba nada ya que en la vida todo se paga . . .

Exentrit - Soluciones SharePoint & Net
  #109 (permalink)  
Antiguo 11/04/2006, 16:47
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Tips and tricks
Pregunta: Como incluir el web service de google en mi aplicacion.
Respuesta: http://www.forosdelweb.com/showthrea...ighlight=rootk
__________________
Nadie roba nada ya que en la vida todo se paga . . .

Exentrit - Soluciones SharePoint & Net
  #110 (permalink)  
Antiguo 24/04/2006, 16:10
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema:Windows Forms
Pregunta:Como evitar que se abra 2 o mas veces mi forma si ya hay una activa.
Respuesta:
http://www.forosdelweb.com/f29/evitar-que-abra-misma-ventana-388134/
  #111 (permalink)  
Antiguo 05/05/2006, 10:57
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Tips and Tricks
Pregunta: Como convertir de VB a C# y viceversa
Respuesta:
http://www.developerfusion.com/tools.../vb-to-csharp/
__________________
Nadie roba nada ya que en la vida todo se paga . . .

Exentrit - Soluciones SharePoint & Net

Última edición por RootK; 19/07/2010 a las 10:23
  #112 (permalink)  
Antiguo 05/05/2006, 10:57
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Wep App
Pregunta: Donde encuentro información de DataList
Respuesta:
http://www.411asp.net/home/tutorial/...g=2&order=desc
  #113 (permalink)  
Antiguo 05/05/2006, 10:57
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Tips and Tricks
Pregunta: Como hacer un upload con Progress Bar
Respuesta:
http://www.codeproject.com/aspnet/Fi...ogress_Bar.asp
  #114 (permalink)  
Antiguo 05/05/2006, 10:59
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Web Forms
Pregunta: Como cargar la ruta de mi aplicacion de forma dinámica
Respuesta:

Ese es mucho de los problemas que han tenido varias personas al momento de manejar las rutas.. porque localmente uno hace tiene algo así:

http://localhost/tuApp/pagina.aspx

Pero cuando subes a produccion queda algo así:

http://www.mysite.com/pagina.aspx

Y como tenías la referencia de tu app no te va a tomar la ruta como debe..por lo cual debes hacer ésto:(al menos así es como lo manejo)

Dentro del global asax declaro una propiedad estática y la cargo en el evento Application_BeginRequest..

Cita:
public static string ApplicationPath = "";
protected void Application_BeginRequest(Object sender, EventArgs e) {
//....
//....
if (HttpContext.Current.Request.ApplicationPath != "/")
ApplicationPath = HttpContext.Current.Request.ApplicationPath;
}
Y listo, siempre tendré la ruta de mi aplicacion para cargarla en cualquier parte de mi proyecto..

Quedando algo así:
Cita:
...background="<%= Global.ApplicationPath %>/Images/Blanco5.png..
  #115 (permalink)  
Antiguo 05/05/2006, 18:06
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Windows Forms
Pregunta: Como colocar un tooltip a mi textbox?
Respuesta:

Arrastramos un control tooltip del toolbox y colocamos el siguiente código:

vb.net
Cita:
Dim ToolTip1 As New System.Windows.Forms.ToolTip()
ToolTip1.SetToolTip(Me.TextBox1, "Hello")
C#
Cita:
System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
ToolTip1.SetToolTip(this.textBox1, "Hello");
  #116 (permalink)  
Antiguo 15/05/2006, 08:36
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Windows Forms
Pregunta: Como hacer mi aplicación multilenguaje ?
Respuesta:
http://www.bhashaindia.com/developer...ingualApp.aspx

Se derivó de éste post:
http://www.forosdelweb.com/showthrea...ghlight=idioma
  #117 (permalink)  
Antiguo 16/05/2006, 15:54
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Windows Forms (tips and tricks)
Pregunta: Como poder arrastar mi forma si no tiene la barra de título (FormBorderStyle.None) ?
Respuesta:

C#
Cita:
using System.Runtime.InteropServices;
............

public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HTCAPTION = 0x2;

[DllImportAttribute ("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

[DllImportAttribute ("user32.dll")]
public static extern bool ReleaseCapture();

private void Form2_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}

extraído de aqui
vb.net
Cita:
Imports System.Runtime.InteropServices
...

Public Const WM_NCLBUTTONDOWN As Int32 = &HA1
Private Const HTCAPTION As Int32 = &H2

<DllImportAttribute("user32.dll")> _
Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function

<DllImportAttribute("user32.dll")> _
Public Shared Function ReleaseCapture() As Boolean
End Function

Private Sub Form1_MouseDown1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
ReleaseCapture()
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End Sub
  #118 (permalink)  
Antiguo 31/05/2006, 12:52
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Windows Forms
Pregunta: Como poner el fondo de color de una columna determinada de mi datagrid
Respuesta:

Voy a usar de ejemplo la base de datos NorthWind

Cuando llenas tu datagrid con un dataset debes asegurarte que tengas asociado un Mapping para usarlo como referencia a través del dataadaptar:

c#
Código:
SqlConnection oConn = new qlConnection("....conexion");
SqlDataAdapter dAdap = new SqlDataAdapter("select * from customers",oConn);
dAdap.TableMappings.Add("Table","Customers"); //debe ser el nombre de tu tabla
DataSet ds = new DataSet();
dAdap .Fill(ds);
vb.net
Código:
 Dim oConn As New SqlConnection("..conexion")
Dim dAdap As New SqlDataAdapter("select * from customers", oConn)
dAdap.TableMappings.Add("Table", "Customers") 'debe ser el nombre de tu tabla
Dim ds As New DataSet
dAdap.Fill(ds)
el segundo paso es crear una clase que herede de DataGridTextBoxColumn y sobreescribir el método Paint

c#
Código:
public class ColoredTextBoxColumn : DataGridTextBoxColumn {
     protected override void Paint(Graphics g, Rectangle bounds, 
	CurrencyManager source, int rowNum, Brush ForeColorBrush, 
			Brush BackColorBrush, bool AlignmentRight) {
			object ObjVal;
			ObjVal = this.GetColumnValueAtRow(source, rowNum);
			
			if (ObjVal!=null) {
				BackColorBrush = Brushes.Red;
				ForeColorBrush = Brushes.Purple;
			}
				
	base.Paint(g, bounds, source, rowNum, BackColorBrush, 
			 ForeColorBrush, AlignmentRight); 
			}
}
vb.net
Código:
 Public Class ColoredTextBoxColumn
        Inherits DataGridTextBoxColumn

        Protected Overloads Overrides Sub Paint(ByVal g As Graphics, _
             ByVal bounds As Rectangle, ByVal source As _
             CurrencyManager, ByVal rowNum As Integer, ByVal _
             ForeColorBrush As Brush, ByVal BackColorBrush As Brush, _
             ByVal AlignmentRight As Boolean)

            Dim ObjVal As Object
            ObjVal = Me.GetColumnValueAtRow(source, rowNum)

            If Not (IsNothing(ObjVal) Or IsDBNull(ObjVal)) Then
                BackColorBrush = Brushes.Red
                ForeColorBrush = Brushes.Purple
            End If

            MyBase.Paint(g, bounds, source, rowNum, _
                BackColorBrush, ForeColorBrush, AlignmentRight)
        End Sub
    End Class
finalmente le asociamos un DataGridTableStyle a nuestro grid ocupando nuestra clase ColoredTextBoxColumn.

c#
Código:
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = "Customers";

ColoredTextBoxColumn col = new ColoredTextBoxColumn();
col.MappingName = "CompanyName";
tableStyle.GridColumnStyles.Add(col);
vb.net
Código:
 
Dim tableStyle As New DataGridTableStyle
tableStyle.MappingName = "Customers"

Dim col As New ColoredTextBoxColumn
col.MappingName = "CompanyName"
tableStyle.GridColumnStyles.Add(col)
Donde col.MappingName = "CompanyName" es el nombre del campo (columna) a la que le queremos asignar el formato del color

El code completo sería:

c#
Código:
SqlConnection oConn = new SqlConnection("...conexion");
SqlDataAdapter dAdap = new SqlDataAdapter("select * from customers",oConn );
dAdap.TableMappings.Add("Table","Customers");
DataSet ds = new DataSet();

dAdap.Fill(ds);
		            			
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = "Customers";

ColoredTextBoxColumn col = new ColoredTextBoxColumn();
col.MappingName = "CompanyName";
tableStyle.GridColumnStyles.Add(col);

dataGrid1.DataSource = ds.Tables["Customers"];
dataGrid1.TableStyles.Add(tableStyle);
vb.net
Código:
   
Dim oConn As New SqlConnection("...conexion")
Dim dAdap As New SqlDataAdapter("select * from customers", oConn)
dAdap.TableMappings.Add("Table", "Customers") 'debe ser el nombre de tu tabla
Dim ds As New DataSet
dAdap.Fill(ds)

Dim tableStyle As New DataGridTableStyle
tableStyle.MappingName = "Customers"

Dim col As New ColoredTextBoxColumn
col.MappingName = "CompanyName"
tableStyle.GridColumnStyles.Add(col)

DataGrid1.DataSource = ds
DataGrid1.TableStyles.Add(tableStyle)

referencias:
http://msdn.microsoft.com/library/de...asicPrimer.asp
http://www.akadia.com/services/dotne...able_cell.html
  #119 (permalink)  
Antiguo 28/06/2006, 09:43
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: Windosw Forms:
Pregunta: Como ajustar la lista del combobox al tamaño del texto sin cambiar el ancho orginal
Respuesta:
http://www.forosdelweb.com/f29/espacio-lista-combobox-405080/

Referencia:
http://www.codeproject.com/cs/combob...xAutoWidth.asp
  #120 (permalink)  
Antiguo 29/06/2006, 18:55
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 2 meses
Puntos: 50
Tema: General
Pregunta: Como crear un Highlighter
Respuesta:
http://www.forosdelweb.com/f29/crear-highlighter-405767/#post1605971
__________________
Nadie roba nada ya que en la vida todo se paga . . .

Exentrit - Soluciones SharePoint & Net

Etiquetas: faq
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 27 personas (incluyéndote)




La zona horaria es GMT -6. Ahora son las 21:58.