Click here to Skip to main content
15,891,896 members
Home / Discussions / C#
   

C#

 
AnswerRe: win32 dll is not working for c# application. Pin
Thomas Krojer5-Jul-11 22:03
Thomas Krojer5-Jul-11 22:03 
GeneralRe: win32 dll is not working for c# application. Pin
Le@rner5-Jul-11 22:09
Le@rner5-Jul-11 22:09 
GeneralRe: win32 dll is not working for c# application. Pin
Thomas Krojer5-Jul-11 23:31
Thomas Krojer5-Jul-11 23:31 
QuestionDataGridView Cell Color Pin
Miwin Solutions5-Jul-11 6:31
Miwin Solutions5-Jul-11 6:31 
AnswerRe: DataGridView Cell Color Pin
Abhinav S5-Jul-11 7:05
Abhinav S5-Jul-11 7:05 
AnswerRe: DataGridView Cell Color Pin
GenJerDan5-Jul-11 8:22
GenJerDan5-Jul-11 8:22 
GeneralRe: DataGridView Cell Color Pin
Miwin Solutions5-Jul-11 11:59
Miwin Solutions5-Jul-11 11:59 
QuestionDatagridview data entry Pin
bugindia5-Jul-11 2:33
bugindia5-Jul-11 2:33 
Hi,

I am currently doing a project in C#.net. I am using a datagridview for data entry purpose.
The first column is a drop down combox column. After selecting the value from the list, I press Enter key. The cursor is not moving to next cell. It is moving to the next row of the same column. How to make it to move to the next column of the same row. Please help me.

private void frmInward_Load(object sender, EventArgs e)
       {
           txtInwardNo.Text=ReturnInwardNo();
           LoadGridcolumns();
           LoadSuppliers();

       }

       private void LoadGridcolumns()
       {
           string SQL;
           OleDbConnection obcon = new OleDbConnection();

           SQL = "";
           SQL = "select '' as ItemGroup,'' as Item,Qty,Amount from InwardDetails";
           obcon.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/MsBakery.mdb";
           obcon.Open();
           OleDbDataAdapter obda = new OleDbDataAdapter(SQL, obcon);
           DataSet ds = new DataSet();
           obda.Fill(ds,"InwardDetails");
           dgvInwardDet.DataSource = ds;
           dgvInwardDet.DataMember = "InwardDetails";

           dgvInwardDet.AutoResizeColumns();

       }

       private string ReturnInwardNo()
       {
           string InwardNo;
           InwardNo = "";

           OleDbConnection obcon = new OleDbConnection();
           OleDbCommand obcmd = new OleDbCommand();
           string SQL;
           bool status;

           status = false;

           try
           {
               obcon.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/MsBakery.mdb";
               obcon.Open();
               SQL = "SELECT TOP 1 InwardNo FROM Inward ORDER BY InwardNo DESC";
               obcmd.CommandText = SQL;
               obcmd.Connection = obcon;

               OleDbDataReader obdr = obcmd.ExecuteReader();
               if (obdr.Read())
               {
                   InwardNo = Convert.ToString(Convert.ToInt32(obdr["InwardNo"].ToString()) + 1);
               }
               else
               {
                  return "1";
               }

           }

           catch (OleDbException ex)
           {
               MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
               status = true;
           }

           finally
           {
               obcon.Close();
               if (!status)
               {
                   obcon = null;
                   obcmd = null;
               }

           }
           return InwardNo;
       }

       private void LoadSuppliers()
       {
           DataGridViewComboBoxColumn dgvcomcol = new DataGridViewComboBoxColumn ();
           //ComboBox cb = new ComboBox();

           dgvcomcol.MaxDropDownItems = 5;
           dgvcomcol.AutoComplete= true;
           //dgvcomcol.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
          // dgvcomcol.FlatStyle = FlatStyle.Flat;
           //dgvcomcol.DisplayMember = "Supplier";
           dgvcomcol.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
           dgvcomcol.DisplayIndex = 0;
          // dgvcomcol.AutoSizeMode = DataGridViewAutoSizeColumnsMode.Fill ;
           dgvcomcol.HeaderText = "Supplier";
           PrepareSupplierCombo(dgvcomcol);
           //dgvcomcol.AutoSizeMode = DataGridViewAutoSizeColumnsMode.Fill;
           //dgvInwardDet.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
           //dgvcomcol.AutoSizeMode = DataGridViewAutoSizeColumnsMode.Fill;
           dgvInwardDet.Columns.Add(dgvcomcol);
           //dgvcomcol.DropDownWidth
           dgvcomcol.Width = 100;


           //dgvcomcol.AutoSizeMode=;


       }

       private void PrepareSupplierCombo(DataGridViewComboBoxColumn col)
       {

           OleDbConnection obcon = new OleDbConnection();
           string SQL;

           obcon.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/MsBakery.mdb";
           obcon.Open();
           SQL = "SELECT SupplierName as Supplier,SupplierID  FROM Suppliers";
           OleDbDataAdapter obda = new OleDbDataAdapter(SQL, obcon);
           DataSet ds = new DataSet();
           obda.Fill(ds, "Suppliers");
           col.Items.Clear();
           col.DataSource = ds.Tables[0];
           col.DisplayMember = "Supplier";
           col.ValueMember = "SupplierID";
           //col.AutoSizeMode = DataGridViewAutoSizeColumnsMode.Fill;
           //col.AutoSizeMode = AutoSizeMode.GrowOnly;
           //col.Sorted = true;

       }

       private void dgvInwardDet_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
       {
           //dgvInwardDet_KeyDown += new DataGridViewEditingControlShowingEventHandler (dgvInwardDet_KeyDown);
           ComboBox com = e.Control as ComboBox;
           //ListBox lb = new ListBox();

           com.AutoCompleteMode = AutoCompleteMode.Suggest;
           com.AutoCompleteSource = AutoCompleteSource.ListItems;
           com.FlatStyle = FlatStyle.Flat;


          // com = Convert.ChangeType(e.Control, ComboBox);


           //dgvInwardDet.KeyDown += new KeyEventHandler(dgvInwardDet_KeyDown);
         //  dgvInwardDet.CellLeave -= new DataGridViewCellEventHandler(dgvInwardDet_CellLeave);
          // com.KeyDown += new KeyEventHandler(ComboBox_KeyDown);

       }



With Regards,
Arun V
AnswerRe: Datagridview data entry Pin
Carmelo La Monica5-Jul-11 11:04
professionalCarmelo La Monica5-Jul-11 11:04 
QuestionCoding style II - O(n) checks instead O(1) or doubling code? [modified] Pin
Lutosław5-Jul-11 1:06
Lutosław5-Jul-11 1:06 
AnswerRe: Coding style II - O(n) checks instead O(1) or doubling code? Pin
Pete O'Hanlon5-Jul-11 1:21
mvePete O'Hanlon5-Jul-11 1:21 
GeneralRe: Coding style II - O(n) checks instead O(1) or doubling code? Pin
Lutosław5-Jul-11 1:38
Lutosław5-Jul-11 1:38 
AnswerRe: Coding style II - O(n) checks instead O(1) or doubling code? Pin
Pete O'Hanlon5-Jul-11 2:48
mvePete O'Hanlon5-Jul-11 2:48 
GeneralRe: Coding style II - O(n) checks instead O(1) or doubling code? Pin
kevinnicol5-Jul-11 10:10
kevinnicol5-Jul-11 10:10 
GeneralRe: Coding style II - O(n) checks instead O(1) or doubling code? Pin
Pete O'Hanlon5-Jul-11 10:15
mvePete O'Hanlon5-Jul-11 10:15 
AnswerRe: Coding style II - O(n) checks instead O(1) or doubling code? Pin
PIEBALDconsult5-Jul-11 3:13
mvePIEBALDconsult5-Jul-11 3:13 
AnswerRe: Coding style II - O(n) checks instead O(1) or doubling code? Pin
BobJanova5-Jul-11 3:30
BobJanova5-Jul-11 3:30 
QuestionWork with Web cam Pin
Abbath13495-Jul-11 0:31
Abbath13495-Jul-11 0:31 
AnswerRe: Work with Web cam Pin
Richard MacCutchan5-Jul-11 6:28
mveRichard MacCutchan5-Jul-11 6:28 
AnswerRe: Work with Web cam Pin
GuyThiebaut5-Jul-11 10:21
professionalGuyThiebaut5-Jul-11 10:21 
QuestionString value in C# Pin
Pierre besquent5-Jul-11 0:13
Pierre besquent5-Jul-11 0:13 
AnswerRe: String value in C# Pin
Richard MacCutchan5-Jul-11 0:22
mveRichard MacCutchan5-Jul-11 0:22 
GeneralRe: String value in C# Pin
Pierre besquent5-Jul-11 0:26
Pierre besquent5-Jul-11 0:26 
AnswerRe: String value in C# Pin
Rhuros5-Jul-11 0:46
professionalRhuros5-Jul-11 0:46 
GeneralRe: String value in C# Pin
Richard MacCutchan5-Jul-11 0:59
mveRichard MacCutchan5-Jul-11 0:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.