Z
Zahid
Hi,
I have a SQLServerCE database linked to my PocketPC
application. What i am doing is reading a row of data
from a table and assigning the values from that row to a
custom control (picture button). The rows in the database
table contain the configuration setting of the custom
designed picture button such as background color,
foreground colour, text etc.
I have about 16 of these custom controls on my form and
the user will regularly need to refresh these so as to
read new picture button settings from the database. The
problem im having is that the refresh speed is a little
slow (4 secs)- causing a delay for the user. I would like
to reduce it to at most 2 secs.
Is there a faster alternative that is not memory
intensive? There will be times probably where I will need
to read 70/80 rows from the database.
Here is my code:
Dim Counter As Integer = 0
Dim bColorFromDB, fColorFromDB As String
gMyCommand.CommandText = "Select ItemText,
ForeGround,Background, ListNo from ListItems"
gRdr = gMyCommand.ExecuteReader
Dim NewStr As String
While (Counter < 16 And gRdr.Read())
bDo_PaintBackGround = False
m = Frm2.Panel1.Controls(Counter)
'Read the Button color setting from the
'database field backgroundColor
m.Text = gRdr.GetString(0)
fColorFromDB = gRdr.GetInt32(1)
bColorFromDB = gRdr.GetInt32(2)
If fColorFromDB = 1 Then
m.ForeColor = Color.FromArgb(0, 0, 0)
ElseIf fColorFromDB = 2 Then
m.ForeColor = Color.FromArgb(0, 0, 168)
ElseIf fColorFromDB = 3 Then
m.ForeColor = Color.FromArgb(0, 168, 0)
Else
End If
If bColorFromDB = 1 Then
m.buttonImg = m.MakeBitmap(0, 0, 0,
m.Width, m.Height)
m.RgbR = 0
m.RgbG = 0
m.RgbB = 0
ElseIf bColorFromDB = 2 Then
m.buttonImg = m.MakeBitmap(0, 0, 168,
m.Width, m.Height)
m.RgbR = 0
m.RgbG = 0
m.RgbB = 168
ElseIf bColorFromDB = 3 Then
m.buttonImg = m.MakeBitmap(0, 168, 0,
m.Width, m.Height)
m.RgbR = 0
m.RgbG = 168
m.RgbB = 0
Else
End If
bDo_PaintBackGround = True
Frm2.Panel1.Controls(Counter).Refresh()
Counter += 1
End While
Thanks in advance.
I have a SQLServerCE database linked to my PocketPC
application. What i am doing is reading a row of data
from a table and assigning the values from that row to a
custom control (picture button). The rows in the database
table contain the configuration setting of the custom
designed picture button such as background color,
foreground colour, text etc.
I have about 16 of these custom controls on my form and
the user will regularly need to refresh these so as to
read new picture button settings from the database. The
problem im having is that the refresh speed is a little
slow (4 secs)- causing a delay for the user. I would like
to reduce it to at most 2 secs.
Is there a faster alternative that is not memory
intensive? There will be times probably where I will need
to read 70/80 rows from the database.
Here is my code:
Dim Counter As Integer = 0
Dim bColorFromDB, fColorFromDB As String
gMyCommand.CommandText = "Select ItemText,
ForeGround,Background, ListNo from ListItems"
gRdr = gMyCommand.ExecuteReader
Dim NewStr As String
While (Counter < 16 And gRdr.Read())
bDo_PaintBackGround = False
m = Frm2.Panel1.Controls(Counter)
'Read the Button color setting from the
'database field backgroundColor
m.Text = gRdr.GetString(0)
fColorFromDB = gRdr.GetInt32(1)
bColorFromDB = gRdr.GetInt32(2)
If fColorFromDB = 1 Then
m.ForeColor = Color.FromArgb(0, 0, 0)
ElseIf fColorFromDB = 2 Then
m.ForeColor = Color.FromArgb(0, 0, 168)
ElseIf fColorFromDB = 3 Then
m.ForeColor = Color.FromArgb(0, 168, 0)
Else
End If
If bColorFromDB = 1 Then
m.buttonImg = m.MakeBitmap(0, 0, 0,
m.Width, m.Height)
m.RgbR = 0
m.RgbG = 0
m.RgbB = 0
ElseIf bColorFromDB = 2 Then
m.buttonImg = m.MakeBitmap(0, 0, 168,
m.Width, m.Height)
m.RgbR = 0
m.RgbG = 0
m.RgbB = 168
ElseIf bColorFromDB = 3 Then
m.buttonImg = m.MakeBitmap(0, 168, 0,
m.Width, m.Height)
m.RgbR = 0
m.RgbG = 168
m.RgbB = 0
Else
End If
bDo_PaintBackGround = True
Frm2.Panel1.Controls(Counter).Refresh()
Counter += 1
End While
Thanks in advance.