I have a EXGrid in a form and want to add button to a cell that either say "Edit" and "Remove", or Have icons for the two. Here is the code I have so far.
With grdGrade
.BeginUpdate
'.DataSource = objCo.DAL.Connection.Execute(sql)
.DefaultItemHeight = 21
.TreeColumnIndex = -1
.MarkSearchColumn = False
.FullRowSelect = exItemSel
.DrawGridLines = exAllLines
.SortOnClick = exNoSort
.BackColorHeader = grdGrade.BackColor
.Appearance = Flat
.BackColorAlternate = Me.BackColor
.SelBackColor = RGB(224, 224, 224)
.SelForeColor = vbBlack
.UseTabKey = True
.Font = Me.Font
.EndUpdate
End With
Set col = grdGrade.Columns.Add("Actions")
col.AllowDragging = False
col.Width = grdGrade.Width * 0.05
col.Editor.AddButton "Edit", , 0
col.Editor.AddButton "Remove", , 0
col.Editor.EditType = ButtonType
Thanks so much for all your help.
I finally got it. When loading the grid I used:
Me.grdGrade.Items.CellValue(h, "Actions") = " Edit "
Me.grdGrade.Items.CellHasButton(h, "Actions") = True
s = Me.grdGrade.Items.SplitCell(h, "Actions")
Me.grdGrade.Items.CellValue(0, s) = " Remove "
Me.grdGrade.Items.CellHasButton(0, s) = True
and it works like a charm
Related
I have created an array to store some excel cell addresses, but while running through a portion of the array with a For Loop (because the values are in order for that portion of the data and its easier than doing each one at a time), but I get an error at line 22,(saData(i,1) = "D" count), right at the "count" variable but I cant figure out why.
'LOADING EXCEL CELL ADDRESS INTO INPUT ARRAY
saData(0,1) = "C3"
saData(1,1) = "F3"
saData(2,1) = "C4"
saData(3,1) = "F4"
saData(4,1) = "F6"
saData(5,1) = "C7"
saData(6,1) = "F7"
saData(7,1) = "C8"
saData(8,1) = "C9"
saData(9,1) = "F9"
saData(10,1) = "C11"
saData(12,1) = "F11"
saData(13,1) = "C13"
saData(14,1) = "F13"
Dim count : count = 16
For i = 15 to 54
saData(i,1) = "D" count
count = count + 1
next'
saData(55,1) = "G59"
saData(56,1) = "F60"
saData(57,1) = "B64"
saData(58,1) = "E64"
For i = 0 to 59
Msgbox saData(i,1)
next
Just try concatenating saData(i,1) = "D"&count
I have a checkbox that I want to verify the checkbox (same names with different values) and to enable/disable if value is an E and it is checked.
function DisableETP() {
var kk = document.getElementsByName('RQR')
for (var i = 0; i < kk.length i++) {
if (kk[i].value == 'E'
and kk[i].checked == true) {
document.getElementById('cp2').disabled = true
document.getElementById('cp2').value = ""
document.getElementById('rtp2').disabled = true
document.getElementById('rtp2').value = ""
document.getElementById('qty2').disabled = true
document.getElementById('qty2').value = ""
document.getElementById('cp3').disabled = true
document.getElementById('cp3').value = ""
document.getElementById('rtp3').disabled = true
document.getElementById('rtp3').value = ""
document.getElementById('qty3').disabled = true
document.getElementById('qty3').value = ""
} else {
document.getElementById('cp2').disabled = false
document.getElementById('cp2').value = ""
document.getElementById('rtp2').disabled = false
document.getElementById('rtp2').value = ""
document.getElementById('qty2').disabled = false
document.getElementById('qty2').value = ""
document.getElementById('cp3').disabled = false
document.getElementById('cp3').value = ""
document.getElementById('rtp3').disabled = false
document.getElementById('rtp3').value = ""
document.getElementById('qty3').disabled = false
document.getElementById('qty3').value = ""
}
}
Do I need to add ; to the lines or...?
Thank you.
In this particular case you don't strictly need semicolons, no.
However your first if statement is invalid because and is not correct javascript syntax, it should be &&.
if (kk[i].value == 'E' && kk[i].checked == true)
You should end each line in javascript with a ;
You also cannot use 'and' as a keyword in an if statement, you have to use && instead.
Its also best to check a boolean value with === instead of ==
im writing an app for accountings of small hotel, i'm working with Visual Studio 2013, on OS: windows 10 (Laptop). After finishing the app just published it using publish wizard, then everything was going great till i copied the published files to another computer contains OS: Windows 7 SP1, the app worked successfully but with a little changes in form design and while preview reports printing.
Here's two pictures to explain what is exactly the problem...
If anyone could explain what's going on and what to do to solve this issue would be respected.
Here's my class which contains printpreviewcontrol code:
Private mRow As Integer = 0
Private newpage As Boolean = True
Private Sub PrintDocument1_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
Try
Dim font36 = New Font("Playball", 36, FontStyle.Regular)
Dim font8 = New Font("Lora", 8, FontStyle.Regular)
Dim font20 = New Font("Lora", 20, FontStyle.Underline)
Dim font16 = New Font("Lora", 16, FontStyle.Regular)
e.Graphics.DrawString("Riviera Beach Chalets", font36, Brushes.Black, New Rectangle(150, 25, 800, 100))
e.Graphics.DrawString("Accounting Reports", font20, Brushes.Black, New Rectangle(650, 45, 300, 50))
e.Graphics.FillRectangle(Brushes.MistyRose, New Rectangle(101, 741, 19, 19))
e.Graphics.DrawString("Accommondation Revenue or Beach Revenue or CoffeeShop Revenue is 0", font8, Brushes.Black, New Rectangle(125, 745, 500, 30))
e.Graphics.DrawString("Amount Received Total :", font16, Brushes.Black, New Rectangle(570, 735, 500, 50))
e.Graphics.DrawString(Report_Database.reporttot, font16, Brushes.Black, New Rectangle(850, 735, 500, 50))
' sets it to show '...' for long text
Dim fmt As StringFormat = New StringFormat(StringFormatFlags.LineLimit)
fmt.LineAlignment = StringAlignment.Center
fmt.Trimming = StringTrimming.EllipsisCharacter
Dim y As Int32 = e.MarginBounds.Top
Dim rc As Rectangle
Dim x As Int32
Dim h As Int32 = 0
Dim row As DataGridViewRow
' print the header text for a new page
' use a grey bg just like the control
If newpage Then
row = Report_Database.DataGridView1.Rows(mRow)
x = 50
For Each cell As DataGridViewCell In row.Cells
' since we are printing the control's view,
' skip invidible columns
If cell.Visible Then
rc = New Rectangle(x, y, cell.Size.Width, cell.Size.Height)
e.Graphics.FillRectangle(Brushes.LightGray, rc)
e.Graphics.DrawRectangle(Pens.Black, rc)
' reused in the data pront - should be a function
Select Case Report_Database.DataGridView1.Columns(cell.ColumnIndex).DefaultCellStyle.Alignment
Case DataGridViewContentAlignment.BottomRight,
DataGridViewContentAlignment.MiddleRight
fmt.Alignment = StringAlignment.Far
rc.Offset(-1, 0)
Case DataGridViewContentAlignment.BottomCenter,
DataGridViewContentAlignment.MiddleCenter
fmt.Alignment = StringAlignment.Center
Case Else
fmt.Alignment = StringAlignment.Near
rc.Offset(2, 0)
End Select
e.Graphics.DrawString(Report_Database.DataGridView1.Columns(cell.ColumnIndex).HeaderText,
Report_Database.DataGridView1.Font, Brushes.Black, rc, fmt)
x += rc.Width
h = Math.Max(h, rc.Height)
End If
Next
y += h
End If
newpage = False
' now print the data for each row
Dim thisNDX As Int32
For thisNDX = mRow To Report_Database.DataGridView1.RowCount - 1
' no need to try to print the new row
If Report_Database.DataGridView1.Rows(thisNDX).IsNewRow Then Exit For
row = Report_Database.DataGridView1.Rows(thisNDX)
h = 0
' reset X for data
x = 50
' print the data
For Each cell As DataGridViewCell In row.Cells
If cell.Visible Then
rc = New Rectangle(x, y, cell.Size.Width, cell.Size.Height)
' SAMPLE CODE: How To
' up a RowPrePaint rule
If Val(row.Cells(2).Value) = 0 Or Val(row.Cells(3).Value) = 0 Or Val(row.Cells(4).Value) = 0 Then
Using br As New SolidBrush(Color.MistyRose)
e.Graphics.FillRectangle(br, rc)
End Using
End If
e.Graphics.DrawRectangle(Pens.Black, rc)
Select Case Report_Database.DataGridView1.Columns(cell.ColumnIndex).DefaultCellStyle.Alignment
Case DataGridViewContentAlignment.BottomRight,
DataGridViewContentAlignment.MiddleRight
fmt.Alignment = StringAlignment.Far
rc.Offset(-1, 0)
Case DataGridViewContentAlignment.BottomCenter,
DataGridViewContentAlignment.MiddleCenter
fmt.Alignment = StringAlignment.Center
Case Else
fmt.Alignment = StringAlignment.Near
rc.Offset(2, 0)
End Select
e.Graphics.DrawString(cell.FormattedValue.ToString(),
Report_Database.DataGridView1.Font, Brushes.Black, rc, fmt)
x += rc.Width
h = Math.Max(h, rc.Height)
End If
Next
y += h
' next row to print
mRow = thisNDX + 1
If y + h > e.MarginBounds.Bottom Then
e.HasMorePages = True
' mRow -= 1 causes last row to rePrint on next page
newpage = True
Button1.Enabled = True
Button4.Enabled = True
If mRow = Report_Database.DataGridView1.RowCount Then
e.HasMorePages = False
Exit Sub
End If
Return
End If
Next
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Critical)
End Try
I'm trying to make a program in Python 3.3.0 to train with Tkinter, but when I try to put images on buttons which are created in a loop, I obtain a few buttons that don't work (I can't click on them and they don't have images), and the last one is working and with the image on it. Here there's the code:
elenco = [immagine1, immagine2, immagine3, immagine 4]
class secondWindow:
def __init__(self):
self.secondWindow = Tk()
self.secondWindow.geometry ('500x650+400+30')
class mainWindow:
def __init__(self):
self.mainWindow = Tk()
self.mainWindow.geometry ('1100x650+100+10')
self.mainWindow.title('MainWindow')
def Buttons(self, stringa):
i = 0
for _ in elenco:
if stringa in _.lower():
j = int(i/10)
self.IM = PIL.Image.open (_ + ".jpg")
self.II = PIL.ImageTk.PhotoImage (self.IM)
self.button = Button(text = _, compound = 'top', image = self.II, command = secondWindow).grid(row = j, column = i-j*10)
i += 1
def mainEnter (self):
testoEntry = StringVar()
self.mainEntry = Entry(self.mainWindow, textvariable = testoEntry).place (x = 900, y = 20)
def search ():
testoEntry2 = testoEntry.get()
if testoEntry2 == "":
pass
else:
testoEntry2 = testoEntry2.lower()
mainWindow.Buttons(self, testoEntry2)
self.button4Entry = Button (self.mainWindow, text = 'search', command = search).place (x = 1050, y = 17)
MW = mainWindow()
MW.mainEnter()
mainloop()
If I try to create buttons in a loop without images, they work:
def Buttons(self, stringa):
i = 0
for _ in elenco:
if stringa in _.lower():
j = int(i/10)
self.button = Button(text = _, command = secondWindow).grid(row = j, column = i-j*10)
i += 1
And if I try to create a button with an image but not in a loop, it works too:
im = PIL.Image.open("immagine1.jpg")
ge = PIL.ImageTk.PhotoImage (im)
butt = Button(text = 'immagine', compound = 'top', image = ge, command = secondWindow).grid(row = 0, column = 0)
Let's say you have images named "image-i.png", i=0,..,9.
When I execute the following code (with python 3.5) I obtain ten working buttons with image and text:
from tkinter import Tk, Button, PhotoImage
root = Tk()
images = []
buttons = []
for i in range(10):
im = PhotoImage(master=root, file="image-%i.png" % i)
b = Button(root, text="Button %i" % i, image=im, compound="left",
command=lambda x=i: print(x))
b.grid(row=i)
images.append(im)
buttons.append(b)
root.mainloop()
Currently I have 6 images layered over top of each other, each with their own corresponding walk animation frame. Each time you walk the Visible property changes and allows the next animation frame to be seen.
The only problem is the bloody flickering when it is passing through any type of object be it, picturebox, form, command button, etc....
After a tiresome day of research I just can't come up with a solution to fix this.
a little snippet of my code if anyone want's to see:
Select Case CharFrame
Case 1
Avatar(0).Visible = True
Avatar(1).Visible = False
Avatar(2).Visible = False
CharFrame = CharFrame + 1
Case 2
Avatar(0).Visible = False
Avatar(1).Visible = True
Avatar(2).Visible = False
CharFrame = CharFrame + 1
Case 3
Avatar(0).Visible = False
Avatar(1).Visible = False
Avatar(2).Visible = True
CharFrame = 1
End Select
Sleep (Timer)
Avatar(0).Top = Avatar(0).Top + moveY
Avatar(1).Top = Avatar(1).Top + moveY
Avatar(2).Top = Avatar(2).Top + moveY
Avatar(3).Top = Avatar(0).Top
Avatar(4).Top = Avatar(1).Top
Avatar(5).Top = Avatar(2).Top
Avatar(6).Top = Avatar(0).Top
Avatar(7).Top = Avatar(1).Top
Avatar(8).Top = Avatar(2).Top
Avatar(9).Top = Avatar(0).Top
Avatar(10).Top = Avatar(1).Top
Avatar(11).Top = Avatar(2).Top
Loop
Avatar(0).Visible = True
Avatar(1).Visible = False
Avatar(2).Visible = False
Found this with Google:
Private Declare Function LockWindowUpdate Lib "USER32" (ByVal hwndLock As Long) As Long
When you like to stop window updating:
LockWindowUpdate <yourform>.hWnd
If you like to continue
LockWindowUpdate False
Found this, did not try it.