GenericEditingControlShowing

by ssi 8. November 2013 07:41

  

Edit Text box for datagridview

private void GenericEditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)

        {

            int colIndex;

            int rowIndex;

            var txtBox = e.Control as TextBox;

            colIndex = tbl_ssi_GLTransactionDataGridView.CurrentCell.ColumnIndex;

            rowIndex = tbl_ssi_GLTransactionDataGridView.CurrentCell.RowIndex;

            if (e.Control is TextBox)

            {

                if (txtBox != null)

                {

                    DataClasses1DataContext dc = new DataClasses1DataContext(glo.ConnectionString);

                    txtBox.CharacterCasing = CharacterCasing.Upper;

                    txtBox.TextChanged += new EventHandler(ItemTxtBox_TextChanged);

                    txtBox.MaxLength = aMaxFieldLength[colIndex];

                    switch (colIndex)

                    {

                        case pCOL_BRANCHNUMBER:

                            txtBox.AutoCompleteSource = AutoCompleteSource.CustomSource;

                            txtBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;

                            var qry = dc.tbl_employee_cost_ctrs.Select(r => new { r.Cost_Center });

                            foreach (var rc in qry)

                                txtBox.AutoCompleteCustomSource.Add(rc.Cost_Center.ToString());

                            break;

                        case pCOL_GL_ACCOUNTNUMBER:

                            txtBox.AutoCompleteSource = AutoCompleteSource.CustomSource;

                            txtBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;

 

                            var qryACCT = dc.tbl_ssi_MVFees.Select(r => new { r.GL_AccountNumber  });

                            foreach (var rc in qryACCT)

                                txtBox.AutoCompleteCustomSource.Add(rc.GL_AccountNumber.ToString());

                            break;

                        default:

                            break;

                    }

 

                }

            }

        }

Tags:

Set DataGridView Columns

by ssi 11. September 2013 10:57

private void SetColumns()
{
ssiMethods.clsStaticMethods.SetupGrid(dataGridView1, Color.LightSalmon, false);



for (int c = 0; c < dataGridView1.Columns.Count; c++)
{
DataGridViewColumn column = dataGridView1.Columns[c];
column.HeaderText = column.HeaderText.Replace("_", " ").ToUpper();

column.Width = 125;
if (column.HeaderText.Contains("AMOUNT"))
{
column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
column.DefaultCellStyle.Format = "##0.00";
column.Width = 100;
}
if (column.HeaderText.Contains("STATUS"))
column.Width = 85;
}

}

Tags: , ,

Blog | CSharp

Ask before Delete Row in a datagridview

by ssi 1. May 2013 20:56

   private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)

        {

            //not here

        }

 

        private void btnDeleteRow_Click(object sender, EventArgs e)

        {

            if (MessageBox.Show("Do you want to delete this Record?", "Confirm Record Deletion",

                MessageBoxButtons.YesNo, MessageBoxIcon.Information)

                == DialogResult.Yes)

            {

                tbl_ssi_BOASuspenseDataGridView.Rows.Remove(tbl_ssi_BOASuspenseDataGridView.Rows[nCurrentRow]);

            }

        }

Tags: , ,

CSharp

Calendar

<<  May 2024  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

RecentComments

None

Development Team @ Shelbysys

We develop custom database applications for our clients. Our development tool of choice is MS Visual Studio. 

Quotations

""All glory is fleeting.""
General George S. Patton, Jr