| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 664 人关注过本帖
标题:datagridview賦值問題
只看楼主 加入收藏
隐圣猫
Rank: 2
等 级:论坛游民
帖 子:7
专家分:36
注 册:2011-12-1
收藏
 问题点数:0 回复次数:0 
datagridview賦值問題
Private Sub Btnquery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnquery.Click
        Dim Query, Query1 As String
        If strFlag = "add" Or strFlag = "edit" Then
            If MessageBox.Show("現在是新增或修改狀態請確認是否退出", "提示", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
                DataGridView1.ReadOnly = True
            Else
                Exit Sub
            End If
        End If

        'query = DataGridView1.Item(0, inti).Value.ToString
        DataGridView1.ReadOnly = True
        If Txtid.Text <> "" Then
            Query = Txtid.Text
        Else
            MessageBox.Show("條件起不可為空!")
            Exit Sub
        End If

        If Txtid.Text <> "" Then
            Query1 = Txtid1.Text

        Else
            MessageBox.Show("條件啟不可為空!")
            Exit Sub
        End If

        Try

            objdataAdapter = New SqlDataAdapter
            objdataAdapter.SelectCommand = New SqlCommand
            objdataAdapter.SelectCommand.Connection = objconnection
            objdataAdapter. = "select  id,name,address,price from t_table"
            ' where id between '" & Query & "' and '" & Query1 & "'"
            objdataAdapter. = CommandType.Text

            objDataset = New DataSet
            If objconnection.State <> ConnectionState.Open Then
                objconnection.Open()
            Else
                MessageBox.Show(ErrorToString)
                MessageBox.Show("打不開")
            End If


            objdataAdapter.Fill(objDataset, "t_table")

            objconnection.Close()

            DataGridView1.AutoGenerateColumns = True '獲取表中的列

            DataGridView1.DataSource = objDataset

            DataGridView1.DataMember = "t_table"


            ObjdataView = New DataView(objDataset.Tables("t_table"))

            ObjcurrecyManager = CType(Me.BindingContext(ObjdataView), CurrencyManager)



        Catch ex As Exception
            MessageBox.Show(ErrorToString)
        End Try

    End Sub

以上代碼,有沒有辦法更改為,不從表中取列出來。而是由在前台加入datagridview的列後。再由代碼將表中的資料賦到對應的列上
搜索更多相关主题的帖子: query 
2011-12-01 15:35
快速回复:datagridview賦值問題
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.059351 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved