How can I prevent all the cells in my DataGrid from being edited without deriving GridColumnStyle
One solution is to remove all the editing controls from the DataGrid.Controls collection. Without these controls, the grid contents cannot be edited. There is a technical problem that requires a little care. You do not want to delete all the controls in DataGrid.Controls as you would lose your scrollbars. The code below deletes all controls except the scrollbars. Alternatively, you could also loop through the controls and only delete the TextBox. [C#] ArrayList al = new ArrayList(); foreach(Control c in this.dataGrid1.Controls) { if(c.GetType() == typeof(VScrollBar) || c.GetType() == typeof(HScrollBar)) { al.Add(c); } } this.dataGrid1.Controls.Clear(); this.dataGrid1.Controls.AddRange((Control[]) al.ToArray(typeof(Control))); [VB.NET] Dim al As New ArrayList() Dim c As Control For Each c In Me.dataGrid1.Controls If c.GetType() = GetType(VScrollBar) Or c.GetType() = GetType(HScrollBar) Then al.Add(c) End If Next c Me.dataGrid1.Controls.Clear() Me.dataGrid1.Controls.AddRange(CType(al.ToArray(GetType(Control)), Control()))
How do I move columns in a datagrid
The columns appear in the order that their column styles were added to the tablestyle being used by the grid. If you want to change this order, you would need to create a new table style, and add the columnstyles in the order you want things to appear. Here is some code snippets that suggest how to do this. [C#] public void MoveColumn(DataGrid _dataGrid, string _mappingName, int fromCol, int toCol) { if(fromCol == toCol) return; DataGridTableStyle oldTS = _dataGrid.TableStyles[_mappingName]; DataGridTableStyle newTS = new DataGridTableStyle(); newTS.MappingName = _mappingName; for(int i = 0; i < oldTS.GridColumnStyles.Count; ++i) { if(i != fromCol && fromCol < toCol) newTS.GridColumnStyles.Add(oldTS.GridColumnStyles[i]); if(i == toCol) newTS.GridColumnStyles.Add(oldTS.GridColumnStyles[fromCol]); if(i != fromCol && fromCol > toCol) newTS.GridColumnStyles.Add(oldTS.GridColumnStyles[i]); } _dataGrid.TableStyles.Remove(oldTS); _dataGrid.TableStyles.Add(newTS); } //sample usage private void button1_Click(object sender, System.EventArgs e) { MoveColumn(myDataGrid, ‘Customers’, 3, 1); } [VB.NET] Public Sub MoveColumn(_dataGrid As DataGrid, _mappingName As String, fromCol As Integer, toCol As Integer) If fromCol = toCol Then Return End If Dim oldTS As DataGridTableStyle = _dataGrid.TableStyles(_mappingName) Dim newTS As New DataGridTableStyle() newTS.MappingName = _mappingName Dim i As Integer i = 0 While i < oldTS.GridColumnStyles.Count If i <> fromCol And fromCol < toCol Then newTS.GridColumnStyles.Add(oldTS.GridColumnStyles(i)) End If If i = toCol Then newTS.GridColumnStyles.Add(oldTS.GridColumnStyles(fromCol)) End If If i <> fromCol And fromCol > toCol Then newTS.GridColumnStyles.Add(oldTS.GridColumnStyles(i)) End If i = i + 1 End While _dataGrid.TableStyles.Remove(oldTS) _dataGrid.TableStyles.Add(newTS) End Sub ’MoveColumn ’sample usage Private Sub button1_Click(sender As Object, e As System.EventArgs) MoveColumn(myDataGrid, ‘Customers’, 3, 1) End Sub ’button1_Click
Is there an easy way to create the ‘Window’ menu that shows the list of child forms open?
Create a ‘Window’ menu in you mdi parent form’s menu and then drop another MenuItem into it, setting it’s MdiList property to true. It will then expand to show all the available mdi children during runtime.
Are server side cursors supported in .NET
No. Nicholas Paldino gives the following response in a position to the microsoft.public.dotnet.framework.odbcnet newsgroup. There are no updateable cursors ANYWHERE in .NET for that matter. The way .NET handles data is you push it into a dataset. The dataset keeps track of the changes that are made, and then you pass the data set back to a data adapter, which will fire off the appropriate insert, update, and delete statements in order to update the underlying data source. All of the data access in .NET is based on a disconnected data model.
Can we see the output of an XAML using XAMLPAD ?
Yes. The output of an XAML file can be viewed using the ’Refresh’ button or by pressing ’F5’ button. When ’Refresh’ button is clicked, XAMLPAD parses and renders the content and displays the output.