Private Function GetComboBoxColumn_Category() As DataGridViewComboBoxColumn Dim ColCombo As New DataGridViewComboBoxColumn Try Using Connection = GetConnection() da = New SqlDataAdapter("SELECT hKey 'iCategory', sCategory FROM tbl_CategoryList WHERE IsObsolete = 0", Connection) dt = New DataTable da.Fill(dt) End Using ColCombo.DataPropertyName = "iCategory" ColCombo.HeaderText = "Category" ColCombo.Name = "iCategory" ColCombo.DataSource = dt ColCombo.ValueMember = "iCategory" ColCombo.DisplayMember = "sCategory" ColCombo.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox Catch ex As Exception ImpensaAlert(ex.Message, MsgBoxStyle.Critical) End Try Return ColCombo End Function Private Sub PopulateExpenditureDetailGrid() Dim TextBoxCell As DataGridViewTextBoxCell Dim strSQL As String = "" Dim dc_Category As DataGridViewComboBoxColumn Dim dc_DelChk As New DataGridViewCheckBoxColumn Try DataGridExpDet.DataSource = Nothing 'DataGridExpDet.Columns.Clear() Label15.Text = "Getting Detail Records..." Application.DoEvents() StrClosedYrs = BuildOpenOrClosedYrsStr(1) 'List Of Closed Years dc_Category = GetComboBoxColumn_Category() DataGridExpDet.Columns.Add(dc_Category) . . . . . . . . . Catch ex As Exception ImpensaAlert(ex.Message, MsgBoxStyle.Critical) End Try End Sub Private Sub DataGridExpDet_CellLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridExpDet.CellLeave If DataGridExpDet.CurrentCell.ColumnIndex = DataGridExpDet.Columns("Amount").Index And Not String.IsNullOrEmpty(DataGridExpDet(DataGridExpDet.CurrentCell.ColumnIndex, DataGridExpDet.CurrentCell.RowIndex).EditedFormattedValue) Then If DataGridExpDet(DataGridExpDet.CurrentCell.ColumnIndex, DataGridExpDet.CurrentCell.RowIndex).EditedFormattedValue < 0 Then DataGridExpDet.Rows(DataGridExpDet.CurrentCell.RowIndex).DefaultCellStyle.ForeColor = Color.Gray End If End If End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)