Está en la página 1de 2

LIMPIAR COMBO ------------Me.cboCajeros.Items.Insert(0, vbNullString) Despues cuando necesito ir a ese primer registro, entonces hago lo siguiente: Me.cboCajeros.SelectedIndex = 0 -----Combo1.

Clear 'Borra el contenido del ComboBox -----Private Sub Form_Load() Dim i% For i = Combo1.ListCount - 1 To 0 Step -1 Combo1.RemoveItem (i) Next i End Sub -----Dim ctl As Object For Each ctl In Me.Controls If TypeOf Ctl Is CheckBox Then ctl.Value = False ElseIf TypeOf Ctl Is TextBox Then ctl.Text = "" ElseIf TypeOf Ctl Is Combobox Then ctl.Text = "" ctl.Clear End If Next -----For Each ctl In Me.Controls If TypeOf ctl Is ComboBox Then ctl.Text = "" End If Next ----comboBox1.DataSource = null; comboBox1.Items.Clear(); LIMPIAR EN FORMA RECURSIVA -------------------------Private Sub ClearTextBox(c As Control) If c.[GetType]().Name = "TextBox" Then c.Text = String.Empty Else For Each child As Control In c.Controls ClearTextBox(child) Next End If End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) For Each c As Control In Me.Controls ClearTextBox(c) Next End Sub

DATAGRIDVIEW ----------------------DataGridViewCellStyle styEstilo; styEstilo = new DataGridViewCellStyle(); styEstilo.BackColor = Color.LightCyan; styEstilo.ForeColor = Color.DarkGreen; styEstilo.Alignment = DataGridViewContentAlignment.TopRight; this.DataGridView1.Columns["NombreColumna"].DefaultCellStyle = styEstilo; // Adicionalmente, tambin puedes utilizar el evento CellFormatting del control grid, para de manera condicional, aplicar un estilo a una celda en funcin de la columna a la que pertenezca dicha celda y su valor. Te adjunto tambin un ejemplo de esto ltimo // private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (this.dataGridView1.Columns[e.ColumnIndex].Name == "NombreColumna") { if (e.Value.ToString() == "UnValor") { e.CellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; e.CellStyle.BackColor = Color.DarkTurquoise; e.CellStyle.ForeColor = Color.WhiteSmoke; e.CellStyle.Font = new Font("Comic Sans MS", 12); } } //

También podría gustarte