How can I place a TextBox in overwrite mode instead of insert mode

You can handle the textbox’s KeyPress event and if you want the keypress to be an overwrite, just select the current character so the keypress will replace it. The attached sample has a derived textbox that has an OverWrite property and a right-click menu that allows you to toggle this property. The snippet below shows you a KeyPress handler that automatically does an overwrite if the maxlength of the textbox has been hit. This does not require a derived class. private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if(textBox1.Text.Length == textBox1.MaxLength && textBox1.SelectedText == ””) { textBox1.SelectionLength = 1; } }

How can I get the selected text in an active gridcell

You need to get the DataGridTextBoxColumn.TextBox member, and retrieve the SelectedText from it for the active cell. The sample shows how you can do this as part of handling this TextBox’s rightClick. This code assumes you have specifically added DataGridTextBoxColumn for each column style. You can also download a VB sample. private void HandleMouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if(e.Button == MouseButtons.Right) { DataGridTableStyle ts = dataGrid1.TableStyles[”customers”]; DataGridTextBoxColumn cs = (DataGridTextBoxColumn)ts.GridColumnStyles[dataGrid1.CurrentCell.ColumnNumber]; MessageBox.Show(”Selected: ” + cs.TextBox.SelectedText); } }

How do I hide the gridlines or set them to a particular color

You can download a working project. Below are VB code snippets showing how you might do these tasks. ’load a bitmap from an embedded resource Dim Bmp As Bitmap ’ from an embedded resource Dim curName As String = ”BitmapVB.sync.bmp” Dim strm As System.IO.Stream = Me.GetType().Assembly.GetManifestResourceStream(curName) Bmp = New Bitmap(strm) PictureBox1.Image = Bmp ….. ….. ’load a bitmap from a file Dim Bmp As Bitmap = Image.FromFile(”c:\sync.bmp”) PictureBox1.Image = Bmp ….. ….. ’modify a bitmap Dim Bmp As Bitmap = PictureBox1.Image.Clone Dim g As Graphics = Graphics.FromImage(Bmp) Dim brush1 As SolidBrush = New SolidBrush(Color.Red) g.DrawString(TextBox1.Text, TextBox1.Font, brush1, 10, 10) PictureBox2.Image = Bmp g.Dispose() …. …. ’save a bitmap as a file Dim dlg As SaveFileDialog = New SaveFileDialog() dlg.Title = ”Save BMP file” dlg.InitialDirectory = ”c:\” dlg.Filter = ”bmp files (*.bmp)|*.bmp|All files (*.*)|*.*” If dlg.ShowDialog = DialogResult.OK Then PictureBox2.Image.Save(dlg.FileName End If

How can I bind an ArrayList to a DataGrid

Here is a technique for binding an arraylist of objects where the objects contain public property that can appear as columns in the datagrid. In this example, the object contains 2 public doubles, one named value and the other named sqrt. To bind this arraylist to a datagrid, add a custom tablestyle that has a MappingName of ”ArrayList”, and then use the property names as the MappingName for each column. Below are some code snippets. You can download a working project that also has code to delete rows and add new rows to the bound arraylist. private void Form1_Load(object sender, System.EventArgs e) { CreateArrayList(); BindArrayListToGrid(); } private void BindArrayListToGrid() { dataGrid1.DataSource = arrayList1; //create a custom tablestyle and add two columnstyles DataGridTableStyle ts = new DataGridTableStyle(); ts.MappingName = ”ArrayList”; int colwidth = (dataGrid1.ClientSize.Width – ts.RowHeaderWidth – SystemInformation.VerticalScrollBarWidth – 5) / 2; //create a column for the value property DataGridTextBoxColumn cs = new DataGridTextBoxColumn(); cs.MappingName = ”value”; //public property name cs.HeaderText = ”Random Number”; cs.Format = ”f4”; cs.Width = colwidth; ts.GridColumnStyles.Add(cs); //create a column for the sqrt property cs = new DataGridTextBoxColumn(); cs.MappingName = ”sqrt”; //public property name cs.HeaderText = ”Square Root”; cs.Format = ”f4”; cs.Width = colwidth; ts.GridColumnStyles.Add(cs); dataGrid1.TableStyles.Clear(); dataGrid1.TableStyles.Add(ts); } private void CreateArrayList() { arrayList1 = new ArrayList(); //add some items Random r = new Random(); for (int i = 0; i < 20; ++i) arrayList1.Add(new RandomNumber(r.NextDouble())); } //create a struct or class that defines what you want in each row //the different columns in the row must be public properties public struct RandomNumber { private double number; public RandomNumber(double d) { number = d; } public double value { get{ return number; } set{ number = value;} } public double sqrt { get {return Math.Sqrt(this.value);} } }