How can I make my last column wide enough to exactly occupy all the client area of the datagrid

If you have added a TableStyle for your grid, then the code below should set the right column width to be the empty space from a button click. If you need to dynamically do this in response to the user sizing other columns, then there may be more work. But if you only need to do it at the end of your Form_Load, then this code might be sufficient. It assumes your datasource is a datatable. You can download a sample project (C#, VB). private void button1_Click(object sender, System.EventArgs e) { int numCols = ((DataTable)(dataGrid1.DataSource)).Columns.Count; //the fudge -4 is for the grid borders int targetWidth = dataGrid1.ClientSize.Width – SystemInformation.VerticalScrollBarWidth – 4; int runningWidthUsed = this.dataGrid1.TableStyles[”customers”].RowHeaderWidth; for(int i = 0; i < numCols – 1; ++i) runningWidthUsed += this.dataGrid1.TableStyles[”customers”].GridColumnStyles[i].Width; if(runningWidthUsed < targetWidth) this.dataGrid1.TableStyles[”customers”].GridColumnStyles[numCols – 1].Width = targetWidth – runningWidthUsed; }

How can I catch the bool values changing in a DataGridBoolColumn

There is no event fired when the boolean value changes. In the attached sample (C#, VB), a BoolValueChanged event has been added to a columnstyle derived from DataGridBoolColumn. Catching the changes requires some effort. The strategy is to save the current value when the cell begins being edited. This is done in an override of Edit. Then in a Paint override, checks are done to see if there is a click in the checkbox cell or if the space bar is hit. If either of these situations happen when the cell is actively being edited, the bool value is changed and the event fired.

How can I make my grid never have an active edit cell and always select whole rows (as in a browser-type grid)

TFor a single row select datagrid, you can get both these behaviors by using a custom column style and overriding its Edit method. In your override, handle unselecting and selecting the current row, and DO NOT call the base class. Not calling the base class keeps the cell from becoming active. Here is a code snippet suggesting how this might be done. You can download a full working project (CS, VB). public class DataGridNoActiveCellColumn : DataGridTextBoxColumn { private int SelectedRow = -1; protected override void Edit(System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Rectangle bounds, bool readOnly,string instantText,bool cellIsVisible) { //make sure previous selection is valid if(SelectedRow > -1 && SelectedRow < source.List.Count + 1) this.DataGridTableStyle.DataGrid.UnSelect(SelectedRow); SelectedRow = rowNum; this.DataGridTableStyle.DataGrid.Select(SelectedRow); } } If you want to handle multi-selections, then there is more work to be done. One solution is to still override Edit as above, but have an empty implementation. Do not have the code the handles the selected row and do not call the baseclass. To handle the selections in this case, subclass the datagrid and override its OnMouseDown virtual method to change all cell clicks into row header clicks. Also override OnCurrentCellChanged to handle moving the current cell with the keyboard. You can download a sample (C#, VB) that implements this functionality.

When I set a TextBox to Readonly or set Enabled to false, the text color is gray. How can I force it to be the color specified in the ForeColor property of the TextBox.

Felix Wu gives this solution in the microsoft.public.dotnet.frameworks.windowsforms newgroup. You can download a VB.NET sample. Override the OnPaint event of the TextBox. For example: protected override void OnPaint(PaintEventArgs e) { SolidBrush drawBrush = new SolidBrush(ForeColor); //Use the ForeColor property // Draw string to screen. e.Graphics.DrawString(Text, Font, drawBrush, 0f,0f); //Use the Font property } Note: You need to set the ControlStyles to ”UserPaint” in the constructor. public MyTextBox() { // This call is required by the Windows.Forms Form Designer. this.SetStyle(ControlStyles.UserPaint,true); InitializeComponent(); // TODO: Add any initialization after the InitForm call }