VB的查询结果以列表形式显示在 DataGrid1 中,如何控制显示列表的某些列的宽度? 大哥大姐救急啊!!!
比如说在DataGrid1查询结果显示列表中”最大推力“这一行太宽了,而”备注“这一行把Access数据库的内容又没有显示完全。我用了Ado控件,源代码如下,应该怎么办?...
比如说在 DataGrid1 查询结果显示列表中 ”最大推力“这一行太宽了,而”备注“这一行把 Access数据库的内容又没有显示完全。
我用了Ado控件,源代码如下,应该怎么办?
Option Explicit
Dim adoCon As New ADODB.Connection
Dim Adors As ADODB.Recordset
Dim sql As String
Private Sub Command1_Click()
DataGrid1.SetFocus
'判断名称是否为空 '连接查询语言
Text1.Text = Trim(Text1.Text) '-------不需要清空,留着下次修改条件再次查询
Text2.Text = Trim(Text2.Text)
Text3.Text = Trim(Text3.Text)
Text4.Text = Trim(Text4.Text)
Text5.Text = Trim(Text5.Text)
Text6.Text = Trim(Text6.Text)
sql = "" '连接查询语言
If Text1 <> "" Then '若Text1不为空则:
If sql <> "" Then sql = sql & " And "
sql = "名称 like '%" & Text1.Text & "%'"
End If
'判断类别是否为空
If Text2 <> "" Then
If sql <> "" Then sql = sql & " And "
sql = "类别 Like '%" & Text2.Text & "%'"
End If
'判断气动布局是否为空
If Len(Trim(Text3)) <> 0 Then
If sql <> "" Then sql = sql & " And "
sql = "气动布局 Like '%" & Text3.Text & "%'"
End If
'判断最大航程是否为空
If Len(Trim(Text4)) <> 0 Then
If sql <> "" Then sql = sql & " And "
sql = "最大航程 >= " & Text4.Text
End If
'判断zaojia1是否为空
If Len(Trim(Text5)) <> 0 Then
If sql <> "" Then sql = sql & " And "
sql = "造价(万元) >= " & Text5.Text
End If
'判断zaojia2是否为空
If Len(Trim(Text6)) <> 0 Then
If sql <> "" Then sql = sql & " And "
sql = "造价(万元) <= " & Text6.Text
End If
If sql <> "" Then sql = " Where " & sql
sql = "Select * From 飞行器" & sql & "" 'SQL查询语言
Adodc1.RecordSource = sql
Adodc1.Refresh
End Sub
Private Sub Command3_Click()
Unload Me
End Sub 展开
我用了Ado控件,源代码如下,应该怎么办?
Option Explicit
Dim adoCon As New ADODB.Connection
Dim Adors As ADODB.Recordset
Dim sql As String
Private Sub Command1_Click()
DataGrid1.SetFocus
'判断名称是否为空 '连接查询语言
Text1.Text = Trim(Text1.Text) '-------不需要清空,留着下次修改条件再次查询
Text2.Text = Trim(Text2.Text)
Text3.Text = Trim(Text3.Text)
Text4.Text = Trim(Text4.Text)
Text5.Text = Trim(Text5.Text)
Text6.Text = Trim(Text6.Text)
sql = "" '连接查询语言
If Text1 <> "" Then '若Text1不为空则:
If sql <> "" Then sql = sql & " And "
sql = "名称 like '%" & Text1.Text & "%'"
End If
'判断类别是否为空
If Text2 <> "" Then
If sql <> "" Then sql = sql & " And "
sql = "类别 Like '%" & Text2.Text & "%'"
End If
'判断气动布局是否为空
If Len(Trim(Text3)) <> 0 Then
If sql <> "" Then sql = sql & " And "
sql = "气动布局 Like '%" & Text3.Text & "%'"
End If
'判断最大航程是否为空
If Len(Trim(Text4)) <> 0 Then
If sql <> "" Then sql = sql & " And "
sql = "最大航程 >= " & Text4.Text
End If
'判断zaojia1是否为空
If Len(Trim(Text5)) <> 0 Then
If sql <> "" Then sql = sql & " And "
sql = "造价(万元) >= " & Text5.Text
End If
'判断zaojia2是否为空
If Len(Trim(Text6)) <> 0 Then
If sql <> "" Then sql = sql & " And "
sql = "造价(万元) <= " & Text6.Text
End If
If sql <> "" Then sql = " Where " & sql
sql = "Select * From 飞行器" & sql & "" 'SQL查询语言
Adodc1.RecordSource = sql
Adodc1.Refresh
End Sub
Private Sub Command3_Click()
Unload Me
End Sub 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询