how to add a new row in datagrid in windows forms if the first column is custom DataGridCombBoxColumnStyle

dear sir i visited your site and also read the FAQ on datagrid.sir i have following problems with data grid plz help me to solve these problem.
1. I have added custom column style to add a combobox to my datagrid.The first column of my grid is this custom combobox.The second column is datagridtextbox column style that is provided by the data grid.Now when i click on the datagridcombobox and i select the particular value from combobox then it doesnot actually right on the grid.But if instead of selecting from the combobox if in first i write the text in the textbox then it appends the blank row in the datagrid and then if again i select the value from the datagridcombobox then it places that value to the datagrid.I think that when we edit the textbox then it makes the datagrid1.nulltext property true.But if the first column is custom column style then it does not make the datagrid1.nulltext property true.Sir plz help me to come out this proble.There is also one thing that i need the code written in VB.Net bcoz i don't know C#.
 
2.The second question is that i want to make calculations on two columns of the bounded datagrid and the i want to assign this result on the another ubound textbox.How can i perform this task .Sir i need the sample code written in VB.Net
 
3.This is the last question that i read the faq on datagrid here is solution for a question written in C#"-
5.34 How can I prevent the Enter key from moving to the next cell when the user is actively editing the cell and presses Enter      

Override the method ProcessKeyPreview in your DataGrid. 
 

 
protected override bool ProcessKeyPreview(ref System.Windows.Forms.Message m) 
 

 
     Keys keyCode = (Keys)(int)m.WParam & Keys.KeyCode; 
 
     if((m.Msg == WM_KEYDOWN || m.Msg == WM_KEYUP) 
 
          && keyCode == Keys.Enter ) 
 
          return false; 
 
     return true; 
 
}
 

Sir the above code is written in C# but sir i need the equivalent code in vb.net bcoz i don't know the C#.
 
sir plz give the answers to the above questions .It is very urgent to get  answers in the short time bcoz i am working on the deadline project and the deadline is very near and i have to impement this project.
Thanx for reading my question.
in wait of your reply


Answer this question

how to add a new row in datagrid in windows forms if the first column is custom DataGridCombBoxColumnStyle

  • jasms

    What exactly are you trying to do.
  • sanske

    I was just wondering if you ever got a solution to this, i having the same problem and even read the same aritcle you read with the C# code. I change my code to this

    Protected Overrides Function ProcessKeyPreview(ByRef msg As Message) As Boolean
            MyBase.ProcessKeyPreview(msg)
            Const WM_SYSKEYDOWN As Int32 = &H104
            Const WM_KEYDOWN As Int32 = &H100
            Dim tmpInt As Int32
            tmpInt = msg.WParam.ToInt32
            Dim keycode As Keys
            keycode = tmpInt
            If keycode = Keys.Enter Then
                Return False
            End If
            Return True


    But i doesn't seem to work.

  • jefseyen

    Hi,

    I've the same problem...
    Did you fine a solution 

    Thanks

  • how to add a new row in datagrid in windows forms if the first column is custom DataGridCombBoxColumnStyle