Refering to Change background color of listview in vb6
I tried this example and does not work as in I see no coloured rows.
I have a command button on my form that loads listview items then once that is finished I call the routine to setup the colour.
I made my picture box visible to see the expected outcome and it is as expected. So effectively setting the ListView's Picture property to the PictureBox's Image property is doing nothing for me.
Anyhow this is my code:
'pbxBG.Visible = True
If lsvPersonalisation.ListItems.Count <> 0 Then
pbxBG.Width = lsvPersonalisation.Width
pbxBG.Height = lsvPersonalisation.ListItems(1).Height * (lsvPersonalisation.ListItems.Count)
pbxBG.ScaleHeight = lsvPersonalisation.ListItems.Count
pbxBG.ScaleWidth = 1
pbxBG.DrawWidth = 1
pbxBG.Cls
Dim i As Integer
For i = 1 To lsvPersonalisation.ListItems.Count
If lsvPersonalisation.ListItems(i).Tag = "1" Then
pbxBG.Line (0, i - 1)-(1, i), &H80FFFF, BF
Else
pbxBG.Line (0, i - 1)-(1, i), &HFFFFFF, BF
End If
Next i
Else
pbxBG.Cls
End If
lsvPersonalisation.Picture = pbxBG.Image
'pbxBG.Visible = False
Related
I want to display the value stored in the varible "total" to the QlineEdit and add value of the variable 'points' to the QlistWidget when the button is clicked.
In the following block of code, i used "self.lineEdit.setText(str(points))" and "self.LW2.addItem(self.points)" to set text to QlineEdit and QlistWidget respectively. Still, the values won't show up.
def display(self):
sqlC = self.databaseConn()
#self.playersList = []
self.pointlist = []
self.total = 0
self.economic_rate=0
if "----SELECT TEAM----" == self.CB1.currentText():
self.msgbox("Warning","Select a team to evaluate")
else:
for x in range(self.LW1.count()):
player=self.LW1.item(x).text()
#print(player)
sqlC.execute("SELECT Scored,Faced,Fours,Sixes,Bowled,Wkts,Catches,Stumping,RO,Given FROM Match WHERE Player = ?",(player,))
score=sqlC.fetchall()
points = FantasyCricket.FantasyCricket.BattingBowlingPoints.batting(score)
points += FantasyCricket.FantasyCricket.BattingBowlingPoints.bowling(score)
self.pointlist.append(points)
#print(points)
self.total += points
#print(self.total)
self.LW2.addItem(str(points))
self.lineEdit.setText(str(self.total))
P.S- the values are displayed correctly on the Shell using print()
I want to call a random color between 8 different colors and display it in a label as its backcolor in Visual Basic. How can I display the colors without repeating a color that has been called out on a specific label?
For example, if color red is called out and displayed in labelA1, how can I make sure that color red won't be called out and displayed in labelB1, labelC1 or labelD1 but can be called out in labelA13 or labelB16?
Below is a picture to help understand the example above.
Use this code to make a list of colors then knock them off the list every time one is used.
Private Function RandomizeLabelColors() As Integer
Randomize()
Dim listOfColors As List(Of Color) = {Color.Red, Color.Blue, Color.Green, Color.Orange}.ToList
Dim labels As List(Of Label) = {Label1, Label2, Label3, Label4, Label5, Label6, Label7, Label8,
Label9, Label10, Label11, Label12, Label13, Label14, Label15, Label16}.ToList
Dim i As Integer = 0
Do Until listOfColors.Count = 0
Dim targetIndex As Integer = Int(Rnd() * listOfColors.Count)
labels(i).BackColor = listOfColors(targetIndex)
labels(i + 4).BackColor = listOfColors(targetIndex)
labels(i + 8).BackColor = listOfColors(targetIndex)
labels(i + 12).BackColor = listOfColors(targetIndex)
listOfColors.RemoveAt(targetIndex)
i += 1
Loop
Return 0
End Function
I have my labels in a 4x4 grid.
-Mg
I am creating an application in vb.net. I have a datagridview control in my VB form. I need to view it on printpreview window with the contents in it. I have other control like labels and textboxes in the form and I can view all in printpreview. In the case of Datagridview control, I have a working printpreview code which I got from net. My problem is, I need to change the x and y positions of datagridview control. With the following code, the datagridview control is displaying over the other controls. I dont know how to do it in this code. Please help me.
I need to change the x and y positions of DataGridView like given in the below code(50 and 225).
e.Graphics.DrawString(Label7.Text, Label7.Font, Brushes.Black, 50, 225)
The code I used to display gridview is given below.
Code :
Dim ColumnCount As Integer = DataGridView1.ColumnCount
Dim RowCount As Integer = DataGridView1.RowCount
Dim CellTopPos As Integer = PrintDocument1.PrinterSettings.DefaultPageSettings.Margins.Top
For Row = 0 To RowCount - 2
Dim CellLeftPos As Integer = PrintDocument1.PrinterSettings.DefaultPageSettings.Margins.Left
For Cell = 0 To ColumnCount - 1
Dim CellValue As String = DataGridView1.Rows(Row).Cells(Cell).Value.ToString()
Dim CellWidth = DataGridView1.Rows(Row).Cells(Cell).Size.Width + 10
Dim CellHeight = DataGridView1.Rows(Row).Cells(Cell).Size.Height
Dim Brush As New SolidBrush(Color.Black)
e.Graphics.DrawString(CellValue, New Font("arial", 9), Brush, CellLeftPos, CellTopPos)
e.Graphics.DrawRectangle(Pens.Black, CellLeftPos, CellTopPos, CellWidth, CellHeight)
CellLeftPos += CellWidth
Next
CellTopPos += DataGridView1.Rows(Row).Cells(0).Size.Height
Next
Use this class .. unfortunately there is characters limit so i can not able to post code
http://www.codeproject.com/Articles/18042/Another-DataGridView-Printer
Good day all! I have a very tricky for me question.
In my application I have button with image inside. All properties of this button:
Me.cmdSelectAll.BackColor = System.Drawing.SystemColors.Control
Me.cmdSelectAll.Image = CType(resources.GetObject("cmdSelectAll.BackgroundImage"), System.Drawing.Image)
Me.cmdSelectAll.ImageAlign = Drawing.ContentAlignment.BottomRight
Me.cmdSelectAll.Cursor = System.Windows.Forms.Cursors.Default
Me.cmdSelectAll.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.cmdSelectAll.ForeColor = System.Drawing.SystemColors.ControlText
Me.cmdSelectAll.Location = New System.Drawing.Point(0, 282)
Me.cmdSelectAll.Name = "cmdSelectAll"
Me.cmdSelectAll.Padding = New System.Windows.Forms.Padding(0, 0, 0, 0)
Me.cmdSelectAll.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.cmdSelectAll.Size = New System.Drawing.Size(22, 22)
Me.cmdSelectAll.TabIndex = 11
Me.cmdSelectAll.TabStop = False
Me.ToolTip1.SetToolTip(Me.cmdSelectAll, "Select All Channels")
Me.cmdSelectAll.UseVisualStyleBackColor = False
When I run it with default text size of win7, the image appears in the center, it's all ok. But when I set some custom value of text size (115%) my image suddenly goes more right and down. It occurs with all of my button's images. Could you please answer me why does this happen and how can i fix this issue? Thanks
I am trying to get my buttons to stay "pressed" once it is released. Right now I am using the improved Buttons Module for corona and I have the default image being the button looking unpressed, and the over image being replaced by an image that looks pressed.
What I am trying to do is once the button is pressed, it stays on the over image. Here is how my code is set up for the button I am testing it on.
local digButton = buttons.newButton{
default = "digButton.png",
over = "digButtonPressed.png",
onEvent = digButtonFunction,
id = "dig"
}
digButton:setReferencePoint(display.CenterReferencePoint)
digButton.x = display.contentWidth/5
digButton.y = display.contentHeight/1.9
Also, I have a function (digButtonFunction) that sets the id of this button to a variable to be used to run an if statement for when the user pushes a button following this one.
This sounds to me like what you really want is a switch. Buttons are not really designed from a UI perspective to do that. The down-state is there just to give feedback to the user that some action happened.
If it were me, I'd not use the button bit at all, but load in to images using display.newImageRect() and draw the downstate first, then the upstate. Built a touch event listener on each one that will hide one or the other. I do this in my games for my sound on/off buttons.
local soundOn = true
local soundOnBtn, soundOffBtn
local function soundToggle(event)
if soundOn then
soundOn = false
soundOnBtn.isVisible = false
soundOffBtn.isVisible = true
else
soundOn = true
soundOnBtn.isVisible = true
soundOffBtn.isVisible = false
end
return true
end
soundOnBtn = display.newImageRect("images/switch_on.png", 46, 36)
soundOnBtn.x = display.contentWidth / 2 + 25
soundOnBtn.y = display.contentHeight / 2 - 15
group:insert(soundOnBtn)
soundOnBtn:addEventListener("tap", soundToggle)
soundOffBtn = display.newImageRect("images/switch_off.png", 46, 36)
soundOffBtn.x = display.contentWidth / 2 + 25
soundOffBtn.y = display.contentHeight / 2 - 15
group:insert(soundOffBtn)
soundOffBtn:addEventListener("tap", soundToggle)
soundOffBtn.isVisible = false