none
vb.net DataGridView 可供動態修改 RRS feed

  • 一般討論

  • 各位好:)

    我想請問有沒有辦法在DataGridViewTextBoxColumn裡能夠動態產生readonly是否為true或false

    我是想要當第一碼不為數字時,能夠做更改的動作

    以下是我的程式,它會產生全部readonly為true

                    DataGridView1.DataSource = ds.Tables(0)

                    For j As Integer = 0 To ds.Tables(0).Rows.Count - 1
                        For k As Integer = 0 To ds.Tables(0).Columns.Count - 1
                             
                            If Not Regex.IsMatch(Mid(ds.Tables(0).Rows(j)(k).ToString(), 1, 1), "^[0-9]+$") Then
                                DataGridView1.Columns(k).ReadOnly = False
                            Else
                                DataGridView1.Columns(k).ReadOnly = True
                            End If
                        Next
                    Next

    2011年9月13日 上午 08:45

所有回覆

  • = =錯那麼小的地方,已經解決完了...  

                     For j As Integer = 0 To ds.Tables(0).Rows.Count - 1
                        For k As Integer = 0 To ds.Tables(0).Columns.Count - 1
                             
                            If Not Regex.IsMatch(Mid(ds.Tables(0).Rows(j)(k).ToString(), 1, 1), "^[0-9]+$") Then
                                DataGridView1.Rows(j).Cells(k).ReadOnly = False
                            Else
                                DataGridView1.Rows(j).Cells(k).ReadOnly = True
                            End If
                        Next
                    Next

    2011年9月13日 上午 10:49