using System
using System.Collections.Generic
using System.ComponentModel
using System.Data
using System.Drawing
using System.Text
using System.Windows.Forms
using System.Collections
using System.IO
public partial class gzxxwh : Form
{
int UpNodeId//上一级节点编号
private void gzxxwh_Load(object sender, EventArgs e)
{
//1、把system,xianxiang,resouce表填充到数据集
//2、显示表单初始内容
this.systemTableAdapter1.Fill(leidaDataSet1.system)
his.xianxiangTableAdapter1.FillleidaDataSet1.xianxiang)
this.resourceTableAdapter1.Fill(leidaDataSet1.resource)
}
/// <summary>
/// exit
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void systemNameComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
//选择分系统。选择之后相关的初始故障信息投影到所选系统内,且只显示isStart=1的初始故障信息
//任务: 1、上级节点设为零,即数据网格显示的是所选分系统初始故障信息,<--,-->两个按钮隐藏
// 2、启用数据网格,过滤数据填充数据网格
// 3、清空后重写提示信息,写跟踪信息
UpNodeId = 0
this.button8.Visible = false
this.button9.Visible = false
this.xianxiangDataGridView.Enabled = true
DataView dv1=new DataView ()
dv1.Table = leidaDataSet1.xianxiang
dv1.RowFilter = "SystemId=" + this.systemNameComboBox.SelectedValue.ToString()+" and "+"isStart=1"
this.xianxiangDataGridView.DataSource = dv1
this.xianxiangDataGridView .Columns[0].HeaderText ="编号"
this.xianxiangDataGridView .Columns[1].HeaderText ="故障现象"
this.xianxiangDataGridView .Columns[2].HeaderText ="是否为初始现象"
this.xianxiangDataGridView .Columns[3].HeaderText ="是否排查终止"
this.xianxiangDataGridView .Columns[4].HeaderText ="结果信息"
this.xianxiangDataGridView .Columns[5].HeaderText ="上级节点编号"
this.xianxiangDataGridView .Columns[6].HeaderText ="分系统编号"
this.xianxiangDataGridView .Columns[7].HeaderText =""
this.label10.Text = "1、选择"+this.systemNameComboBox.Text +"分系统的故障诊断息"
this.listBox1.Items.Clear()
this.listBox1.Items.Add("开始-->" + this.systemNameComboBox.Text)
}
private void xianxiangDataGridView_RowEnter(object sender, DataGridViewCellEventArgs e)
{
this.tabControl2.Enabled = true
this.textBox9.Text = xianxiangDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString()
this.textBox5.Text =
datagridview是vb控件,在datagridview中显示数据从 access 数据库步骤如下:
1 在vb中创建窗体:
插入datagrid:
2 编写查询数据的代码:
Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sqlStr As String
Dim i As Integer
Dim contStr As String
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0Data Source=" &App.Path &"\test.mdbPersist Security Info=False"
cn.Open
sqlStr = "select 题号,题目内容,答案 from Tradition where 题目内容 like '%" &Text1.Text &"%" &Chr(39)
rs.CursorLocation = adUseClient
rs.Open sqlStr, cn, adOpenDynamic, adLockPessimistic
If rs.RecordCount >0 Then
Set DataGrid1.DataSource = rs
Else
MsgBox "查询无记录"
End If
Me.DataGrid1.Visible = True
Me.DataGrid1.Refresh
rs.Close
End Sub
3 输入关键字,查询效果如下:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)