How can I prevent a ComboBox and DataGrid bound to the same DataTable from sharing the same current position

If you have two controls bound to the same datasource, and you do not want them to share the same position, then you must make sure that the BindingContext member of one control differs from the BindingContext member of the other control. If they have the same BindingContext, they will share the same position in the datasource. If you add a ComboBox and a DataGrid to a form, the default behavior is for the BindingContext member of each of the two controls to be set to the Form’s BindingContext. Thus, the default behavior is for the DataGrid and ComboBox to share the same BindingContext, and hence the selection in the ComboBox is synchronized with the current row of the DataGrid. If you do not want this behavior, you should create a new BindingContext member for at least one of the controls. [C#] private void Form1_Load(object sender, System.EventArgs e) { this.myDataTable = GetATable(); //get a datatable somehow… this.dataGrid1.DataSource = myDataTable; //set a new binding context for the combobox this.comboBox1.BindingContext = new BindingContext(); this.comboBox1.DataSource = myDataTable; this.comboBox1.DisplayMember = ‘Col1’; this.comboBox1.ValueMember = ‘Col1’; } [VB.NET] Private Sub Form1_Load(ByVal sender as Object, ByVal e as System.EventArgs) Me.myDataTable = GetATable() ’get a datatable somehow… Me.dataGrid1.DataSource = myDataTable ’set a new binding context for the combobox Me.comboBox1.BindingContext = New BindingContext() Me.comboBox1.DataSource = myDataTable Me.comboBox1.DisplayMember = ‘Col1’ Me.comboBox1.ValueMember = ‘Col1’ End Sub

How can I programmatically prevent the combobox from dropping

You can avoid the combobox dropping by overriding its WndProc method and ignoring the WM_LBUTTONDOWN and WM_LBUTTONDBLCLK. [C#] public class MyComboBox : ComboBox { protected override void WndProc(ref System.Windows.Forms.Message m) { if(m.Msg == 0x201 //WM_LBUTTONDOWN || m.Msg == 0x203) //WM_LBUTTONDBLCLK return; base.WndProc(ref m); } } [VB.NET] Public Class MyComboBox Inherits ComboBox Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If m.Msg = &H201 OrElse m.Msg = &H203 Then ’WM_LBUTTONDOWN or WM_LBUTTONDBLCLK Return End If MyBase.WndProc(m) End Sub ’WndProc End Class ’MyComboBox

How do I disable pasting into a TextBox (via Ctrl + V and the context menu)?

First set the ContextMenu property of the TextBox to a dummy, empty ContextMenu instance. This will prevent the default context menu from showing. Then, override the ProcessCmdKey method as follows in a TextBox derived class: // In C# protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if(keyData == (Keys.Control | Keys.V)) return true; else return base.ProcessCmdKey(ref msg, keyData); } ’ In VB.Net Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean If keyData =(Keys.Control | Keys.V) Then Return True Else Return MyBase.ProcessCmdKey( msg, keyData) End If End Function