这是我的表:
INSERT INTO `opcije_mp` VALUES (1,'MP default','1','1','1','1','1','2','3','1','1','1','1','1','1','1','1');
数据样本:
<dxnav:TileBar x:FieldModifier="public" x:Name="maloprodaja" Margin="10,0,0,10" ItemSpacing="5" FlyoutShowDirection="Default" ItemColorMode="Standard" AllowItemSelection="true" Orientation="vertical" HorizontalAlignment="LEFT" Padding="20,0,20,20">
<dxnav:TileBarItem Name="Prodaja" Content="Prodaja" Background="#FF901B45" TileGlyph="{dx:DXImage Image=BOSale_32x32.png}" Width="150"/>
<dxnav:TileBarItem Name="Kalkulacije" Content="Kalkulacije" Background="#FF901B45" TileGlyph="{dx:DXImage Image=BOTask_32x32.png}" Width="150"/>
</dxnav:TileBar>
我的目标是使用列名来识别我在Tilebar中的按钮,并使用列下的值来运行一些代码(隐藏,显示,重新绘制,禁用)按钮
Public Function vratiTipke()
Dim result = New List(Of ReturnList)
Try
ManageConnection(False, konekcija) 'Open connection
Dim strQuery As String = "SELECT * FROM info.opcije_mp where idopcije_mp = 1;"
Dim SqlCmd As New MySqlCommand(strQuery, dbCon)
Dim reader As MySqlDataReader = SqlCmd.ExecuteReader()
While reader.Read()
Dim TempResult As New ReturnList
TempResult.tipka1 = reader(0)
TempResult.tipka2 = reader(1)
result.Add(TempResult)
End While
reader.Close()
Catch ex As MySqlException
Console.WriteLine("Error: " & ex.ToString())
Finally
ManageConnection(True, konekcija) 'Close connection
End Try
Return result
End Function
Public Class ReturnList
Public Property tipka1 As String
Public Property tipka2 As String
End Class
我的当前函数仅返回列
下的值IFormInfo
我的按钮名称与我的表格中的列名称相同(不包括用于标识“预设”的前两列)
答案 0 :(得分:0)
您可以按实际名称识别列。
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("opcije_mp")
Dim fld As DAO.Field
For Each fld In rs1.Fields
'Make an array or something, these should be LTR order
Next
Set fld = Nothing
例如,您也可以使用循环来设置按钮名称。