private void input_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyData == Keys.Enter)
{
MessageBox.Show("Pressed enter.");
}
}
lunes, 30 de octubre de 2017
Detectar tecla Enter en un TextBox
Sumar días a un DateTimePicker
Dim x As String = DateTimePicker1.Value.AddDays(1).ToString("yyyy-MM-dd")
miércoles, 25 de octubre de 2017
Llamar al evento DataGridView_CellClick desde un botón
e = New DataGridViewCellEventArgs(col, row)
dgvtotales_CellClick(Nothing, e)
dgvtotales_CellClick(Nothing, e)
private void kryptonbtnEdit_Click(object sender, EventArgs e)
{
//set parameters of your event args
var eventArgs = new DataGridViewCellEventArgs(yourColumnIndex, yourRowIndex);
// or setting the selected cells manually before executing the function
kryptonDataGridView1.Rows[yourRowIndex].Cells[yourColumnIndex].Selected = true;
kryptonDataGridView1_CellDoubleClick(sender, eventArgs);
}
fuente: https://stackoverflow.com/questions/27838861/how-to-call-a-datagridview-event-with-a-click-of-a-button
jueves, 19 de octubre de 2017
Obtener el nombre de la base de datos
Public Function returndb(ByVal conex As String) As String
Dim data() As String = conex.Split(";")
Dim db As String = ""
For Each rd As String In data
If rd.Contains("atalog") Then
db = rd.Split("=")(1)
Exit For
End If
Next
Return db
End Function
Dim data() As String = conex.Split(";")
Dim db As String = ""
For Each rd As String In data
If rd.Contains("atalog") Then
db = rd.Split("=")(1)
Exit For
End If
Next
Return db
End Function
martes, 17 de octubre de 2017
Obtener la fila y columna seleccionada
Dim var As Integer = dgv1.CurrentCell.RowIndex
Dim var As Integer = dgv1.CurrentCell.ColumnIndex
Dim i As Integer = DataGridView1.CurrentRow.Index
Dim var As Integer = dgv1.CurrentCell.ColumnIndex
Dim i As Integer = DataGridView1.CurrentRow.Index
Etiquetas:
ColumnIndex,
CurrentCell,
CurrentRow,
DataGridView,
RowIndex
viernes, 13 de octubre de 2017
DataGridView opciones
Cambiar el colo azul de seleccion que viene por defecto:
dgv.DefaultCellStyle.SelectionBackColor = Color.Yellow
AllowUserToResizeRow = False
SelectionMode = FullRowSelect
RowHeadersVisible = False
Cambiar el color de la cabecera:
dgv.ColumnHeadersDefaultCellStyle.BackColor = Color.LightSkyBlue
Properties:
EnableHeaderVisualStyles: False
Centrar el nombre de todas columnas:
'Dim dgvColumnHeaderStyle As New DataGridViewCellStyle()
'dgvColumnHeaderStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
'dgv.ColumnHeadersDefaultCellStyle = dgvColumnHeaderStyle
Centrar el nombre de una columna:
dgv.Columns("Column1").HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter
fuente:
https://stackoverflow.com/questions/4550836/how-can-i-center-the-heading-in-a-column-on-a-datagridview
miércoles, 11 de octubre de 2017
Verificar si existe un procedimiento almacenado
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'SP_ver_rcv')
BEGIN
DROP PROCEDURE SP_ver_rcv
END
GO
CREATE PROCEDURE SP_ver_rcv
AS
BEGIN...
.
.
.
fuente: https://msdn.microsoft.com/en-us/library/dd996513.aspx
BEGIN
DROP PROCEDURE SP_ver_rcv
END
GO
CREATE PROCEDURE SP_ver_rcv
AS
BEGIN...
.
.
.
fuente: https://msdn.microsoft.com/en-us/library/dd996513.aspx
Aceptar sólo números en un Textbox y otro caracter
Private Sub tbfecha_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles tbfecha.KeyPress
If Not Char.IsControl(e.KeyChar) AndAlso Not Char.IsDigit(e.KeyChar) AndAlso (e.KeyChar <> "-") Then
e.Handled = True
End If
End Sub
If Not Char.IsControl(e.KeyChar) AndAlso Not Char.IsDigit(e.KeyChar) AndAlso (e.KeyChar <> "-") Then
e.Handled = True
End If
End Sub
Aceptar sólo números en un TextBox
Private Sub tbrut_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles tbrut.KeyPress
If Not Char.IsControl(e.KeyChar) AndAlso Not Char.IsDigit(e.KeyChar) Then
e.Handled = True
End If
End Sub
If Not Char.IsControl(e.KeyChar) AndAlso Not Char.IsDigit(e.KeyChar) Then
e.Handled = True
End If
End Sub
Deshabilitar clic derecho del mouse en un TextBox
Private Sub tbrut_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles tbrut.MouseDown
tbrut.ContextMenu = New ContextMenu()
End Sub
tbrut.ContextMenu = New ContextMenu()
End Sub
Suscribirse a:
Entradas (Atom)