5 Replies - 1089 Views - Last Post: 02 October 2011 - 09:26 AM Rate Topic: -----

#1 sidyusuf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 15-September 11

noneditable datagridview

Posted 02 October 2011 - 07:06 AM

hi frnds,
i have a datagridview with checkbox column including some others columns,my problem is that i want to make the datagrid noneditable except checkbox column..how do accomplish this task??????
my second question is that i have roll no column in datagridview.i m able to generate roll no through looping but unable to save them to database...
Is This A Good Question/Topic? 0
  • +

Replies To: noneditable datagridview

#2 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: noneditable datagridview

Posted 02 October 2011 - 07:20 AM

Yes, put the property of columns which you need to be read-only to true and others to false, like:
DataGridView1.Columns(0).ReadOnly = False
DataGridView1.Columns(1).ReadOnly = True


How were you trying to save them to the database?
Was This Post Helpful? 0
  • +
  • -

#3 sidyusuf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 15-September 11

Re: noneditable datagridview

Posted 02 October 2011 - 07:30 AM

thnxs sir for my first question...in my second question i have the following code:
Private Sub btngenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngenerate.Click
        For i As Integer = TextBox2.Text - 1 To (TextBox1.Text - 1)
            dgvroll.Rows(i).Cells(0).Value = substrclasssid & "0" & (i + 1)
        Next
        MsgBox("updated")
    End Sub


i want to save them to database..how to do that?
Was This Post Helpful? 0
  • +
  • -

#4 sidyusuf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 15-September 11

Re: noneditable datagridview

Posted 02 October 2011 - 07:47 AM

DataGridView1.Columns(0).ReadOnly = False
DataGridView1.Columns(1).ReadOnly = True
sir nothing happens when i apply this code..the checkbox column is still noneditable..
Was This Post Helpful? 0
  • +
  • -

#5 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: noneditable datagridview

Posted 02 October 2011 - 08:07 AM

Make DataGridView readOnly property to false, and apply that code in load event.
In saving I need to see how you retrieve those data from database. One question, so you have empty column in database to save those values?
Was This Post Helpful? 0
  • +
  • -

#6 sidyusuf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 15-September 11

Re: noneditable datagridview

Posted 02 October 2011 - 09:26 AM

Dim ds As New DataSet
  Dim da = New OleDbDataAdapter("SELECT distinct Roll,Papername,from class ", con)
 da.fill(ds)
 dgvpapers.DataSource = ds.Tables(0)



the checkbox column is loaded seperately as:
Dim checkCol As DataGridViewCheckBoxColumn = New DataGridViewCheckBoxColumn()
        checkCol.HeaderText = "Select"
        dgvpapers.Columns.Add(checkCol)


the roll column is not empty.it is filled already.

This post has been edited by sidyusuf: 02 October 2011 - 09:27 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1