inseting into dataGrid

1)how can i know if the user is know inserting inforamtion in new row 2)w can i pervent him to add i want to him just to update 3)how can i put a value (the user can't change it)into a column

2 Replies

FR Frank September 26, 2002 08:39 PM UTC

> 1)how can i know if the user is know inserting inforamtion in new row > > 2)w can i pervent him to add i want to him just to update > > 3)how can i put a value (the user can't change it)into a column I can answer the 3rd part. To get a default value, you can set a default value for the underlying column (of the DataSet). DataSetName.TableName.FieldNameColumn.DefaultValue = "Default"; Keeping the user from editing the value can be done by adding DataGridColumnStyle to you DataGrid -- one of the fields is ReadOnly.


AD Administrator Syncfusion Team October 3, 2002 05:49 PM UTC

> 1)how can i know if the user is know inserting inforamtion in new row > > 2)w can i pervent him to add i want to him just to update > > 3)how can i put a value (the user can't change it)into a column In regards to question #2. See DataGrid Faq question #5.5 Disabling the add new row. To do this in vb.net: Dim strCS As String = "Provider=Microsoft.JET.OLEDB.4.0;data source=C:\northwind.mdb" Dim strSQL As String = "SELECT * FROM customers" ' Connection Object. Dim oConn As New OleDb.OleDbConnection(strCS) 'Create data adapter object. Dim oDAdapt As New OleDb.OleDbDataAdapter(strSQL, oConn) ' Create a dataset object & fill with data using data adapter's fill method. Dim oDSet As New DataSet() oDAdapt.Fill(oDSet, "customers") ' Attach dataset's DefaultView to the DataGrid control. dgTable.DataSource = oDSet.Tables("customers") ' Get reference to dataview and disable allow new. Dim oDView As DataView = oDSet.Tables("customers").DefaultView oDView.AllowNew = False ' If you wanted to allow users to add new rows but without using ' the tab key you could do this, create an ' insert function along the lines of the following. Dim iCount As Integer Dim oDView As DataView = oDSet.Tables("customers").DefaultView iCount = dgTable.BindingContext(dgTable.DataSource, dgTable.DataMember).Count If dgTable.CurrentRowIndex <> iCount Then oDView.AllowNew = True oDView.AddNew() dgTable.CurrentRowIndex = iCount dgTable.Focus() dvTable.AllowNew = False End If

Loader.
Up arrow icon