|
I thought this might have fixed it, but it does not.
I did do some testing though, and discovered that the offset is directly related to the size of the Form. However, this has not helped me much.
I have my monitor resolution at 1440x900 and the Form size is the same.
I tried:
YRadius - (900 / YRadius) and XRadius - (1440 / XRadius) to create the offset.
Then I draw the circle using:
gfxCharacterCircle.DrawEllipse(penCharacter, MousePositionX-Xradius, MousePositionY-Yradius, radius, radius)
It is still not placing the circle's center directly on the mouse though.
I must say, this is the most frustrating thing in the world right now. I will admit, my math is a bit rusty, but I didn't think it was this bad...
|
|
|
|
|
i am looking for a code to Print preview and print listview in printer in vb.net or 2008.please assist.thanks.
|
|
|
|
|
As far as I'm aware, you can't print a listview directly. What you want to do is use printdocuments.
Google search[^]
Try those, and let us know if you have any further questions.
|
|
|
|
|
Try
m_SelectedStyle = New DataGridViewCellStyle()
m_SelectedStyle.BackColor = Color.LightBlue
m_SelectedStyle.BackColor = SystemColors.Highlight
DataGridView1.ReadOnly = True
Dim SQLString As String = "SELECT id, bedrijfsnaam, startdatum, vervaldatum, omschrijving, netto, bruto, opmerkingen FROM Facturen"
Dim DataSet As New DataSet()
Dim OleDbDataAdapter As System.Data.OleDb.OleDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter(SQLString, oleConn)
oleConn.Open()
OleDbDataAdapter.Fill(DataSet, "Facturen")
DataGridView1.DataSource = DataSet.Tables("Facturen")
'here the colors starts
DataGridView1.Rows(1).DefaultCellStyle.BackColor = Color.Blue
Dim vandaag As String = Today
Dim i As Integer = 0
For Each row As DataGridViewRow In DataGridView1.Rows
If DataGridView1.Item(2, i).Value() = vandaag Then
DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.IndianRed
ElseIf DataGridView1.Item(2, i).Value() > vandaag Then
DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LightGreen
End If
i = i + 1
Next
DataGridView1.AutoResizeColumns()
oleConn.Close()
Catch ex As Exception
blabla
End Try
Even if i try to just color without conditions it doesnt work something like:
DataGridView1.Rows(2).DefaultCellStyle.BackColor = Color.LightGreen
But whyyyyy....
|
|
|
|
|
Hi,
1.
that is unreadable; use PRE tags to get a non-prop font and proper indentation.
2.
don't swallow exceptions, they provide useful information.
3.
in my experience, DGV backcolor only works on non-empty cells. My "CP Vanity" article uses it a lot (it is C#, doesn't really matter).
|
|
|
|
|
1. True.
2. True.
3. Not True.
|
|
|
|
|
The last one is indeed not true...
For your first 2 points thx 4 the advice...
So my code between pre thags(sorry 4 that)
m_SelectedStyle = New DataGridViewCellStyle()
m_SelectedStyle.BackColor = Color.LightBlue
m_SelectedStyle.BackColor = SystemColors.Highlight
DataGridView1.ReadOnly = True
Dim SQLString As String = "SELECT id, bedrijfsnaam, startdatum, vervaldatum, omschrijving, netto, bruto, opmerkingen FROM Facturen"
Dim DataSet As New DataSet()
Dim OleDbDataAdapter As System.Data.OleDb.OleDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter(SQLString, oleConn)
oleConn.Open()
OleDbDataAdapter.Fill(DataSet, "Facturen")
DataGridView1.DataSource = DataSet.Tables("Facturen")
'here i do the code to check if a field is smaller then a certain date
Dim vandaag As String = Today
Dim i As Integer = 0
For Each row As DataGridViewRow In DataGridView1.Rows
If DataGridView1.Item(2, i).Value() > vandaag Then
DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.IndianRed
ElseIf DataGridView1.Item(2, i).Value() < vandaag Then
DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.LightGreen
End If
i = i + 1
Next
oleConn.Close()
I hope is more clear now
Thx 4 the answers already
greetz
|
|
|
|
|
That's because you got a bounded datagridview.
If you want colors, you'll need to put it in a CellFormatting Sub, like so:
Public Sub DataGridView1_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting
End Sub
|
|
|
|
|
The celformatting is updating all the time...
I think it's not a good practice 4 memory use etc...
If i place a messagebox in the sub's it's popping up all the time...
Anyway Thx
greetz
|
|
|
|
|
Ofcourse it is. It's like a Paint routine on a Form, Panel, etc.
Therefore it is not a good idea to put a messagebox in there, just do your coloring.
|
|
|
|
|
Correction: The issue is not the resizing as the resized photos view fine outside of the report. The issue appears moreso to be that when the image is stored in a datatable and put into a crystal report via binary stream, it comes out pixelated. Is there a method to store those in the datatable and transfer them to CR in a less pixelated manner?
I use the following function to resize an image that gets merged into a crystal report to make a photo book.
Private Sub importPhoto(ByVal strFileName As String, ByRef Width As Int32, ByRef Height As Int32, ByVal saveLocation As String, ByRef objDataRow As DataRow)
Dim imgPhoto As New Bitmap(strFileName)
Dim sourceWidth As Int32 = imgPhoto.Width
Dim sourceHeight As Int32 = imgPhoto.Height
Dim sourceX As Int32 = 0
Dim sourceY As Int32 = 0
Dim destX As Int32 = 0
Dim destY As Int32 = 0
Dim nPercent As Single
Dim nPercentW As Single
Dim nPercentH As Single
'If Not File.Exists(saveLocation & "\" & Path.GetFileName(strFileName)) Then
nPercentW = Width / CSng(sourceWidth)
nPercentH = Height / CSng(sourceHeight)
If nPercentH < nPercentW Then
nPercent = nPercentH
destX = System.Convert.ToInt16((Width - (sourceWidth * nPercent)) / 2)
Else
nPercent = nPercentW
destY = System.Convert.ToInt16((Height - (sourceHeight * nPercent)) / 2)
End If
Dim destWidth As Int32 = sourceWidth * nPercent
Dim destHeight As Int32 = sourceHeight * nPercent
Dim bmPhoto As New Bitmap(Width, Height, PixelFormat.Format24bppRgb)
bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution)
Dim g As Graphics = Graphics.FromImage(bmPhoto)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.Clear(Color.White)
g.DrawImage(imgPhoto, New Rectangle(destX, destY, destWidth, destHeight), New Rectangle(sourceX, sourceY, sourceWidth, sourceHeight), GraphicsUnit.Pixel)
g.Dispose()
imgPhoto.Dispose()
bmPhoto.Save(saveLocation & "\" & Path.GetFileName(strFileName), Imaging.ImageFormat.Jpeg)
Dim fs As New FileStream(saveLocation & "\" & Path.GetFileName(strFileName), FileMode.Open, FileAccess.Read)
Dim Image(fs.Length - 1) As Byte
fs.Read(Image, 0, Convert.ToInt32(fs.Length))
fs.Close()
objDataRow(11) = Image
File.Delete(saveLocation & "\" & Path.GetFileName(strFileName))
GC.Collect()
'Else
' Dim fs As New FileStream(saveLocation & "\" & Path.GetFileName(strFileName), FileMode.Open, FileAccess.Read)
' Dim Image(fs.Length - 1) As Byte
' fs.Read(Image, 0, Convert.ToInt32(fs.Length))
' fs.Close()
' fs.Dispose()
' objDataRow(11) = Image
' Image = Nothing
' GC.Collect()
'End If
End Sub
Ignoring the commented out parts, the issue is that while the picture does come out at the desired size, it becomes very pixelated. Is this a result of the graphics interpolation mode? Or is there a better method of doing this? The issue is that I get large resolution pictures (2816 x 2112) that end up in a 300 x 200 box in the report. This makes the report giant and time consuming (It is 12,000 pages to begin with) so I shrink the pictures down to a more manageable size in order to speed up performance.
Anyone have an opinion on this?
Cheers, --EA
modified 22-Sep-11 12:21pm.
|
|
|
|
|
Hi,
1.
a 12,000 page report? I assume you're not reading that on a display. When printing (parts of) it, your printer is likely to have say 300dpi, i.e. your 200*300 image will either be smaller than 1 sq.inch, or the printer driver will have to scale it up again.
2.
You have an intermediate step saving bmPhoto to a file.Try using another image format (say bmp) as a test to say whether your bmPhoto itself is of sufficient quality.
BTW: you don't need to save to file, save to a MemoryStream instead.
3.
You're using PixelFormat.Format24bppRgb ; I wouldn't do that, not sure it really matters though.
4.
bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution) is something I wouldn't do either. Again not sure it matters.
5.
GC.Collect() is a bad idea; you'd better dispose of disposable objects you no longer need, such as bmPhoto and fs . Then let the GC do its job on its own pace.
|
|
|
|
|
1. These reports are read on screen, not printed. You are correct in that.
2. Thank you, I will implement that.
3. I will try removing that and test the results.
4. I will try that as well.
5. I did let it collect at it's own pace as I like to be gentle, but it ran out of memory as it was storing images faster than the garbage would collect and dispose of unwanted garbage. I will try implementing more dispose patterns.
Thank you for the suggestions, your input is always valuable.
Cheers, --EA
|
|
|
|
|
code peepz,
Why does my vs 2010 is not working anymore???
I googled but nothing had solved the large amount of questions.
I get this error:
Microsoft visual studio had encounter an error and needs to be closed
then i get => mediacontextnotificationwindow : devenv.exe
unknown software error (0xe0434352) location : 0x752dd36f
Can somebody help me out??
Thx in advance
|
|
|
|
|
2 options;
a) uninstall - reinstall
b) reinstall on top
|
|
|
|
|
Hi,
Googling a bit, I found:
1. the possibility you're using a networked disk which happens to have some problems;
2. you're not alone; see here[^] for instance.
|
|
|
|
|
hi all, here my problem is i'm preety new to vb.net programming. but have a little knowledge in vb6 programming.
when form loads in listview are displayed some items.
when you doubleclick selected item, then in the textboxes near listview will display all the information of item selected.
can anyone of you suggest me something else?
till now studied this code :
private sub listview1_dblclick()
for i=1 to listview1.listitems.count
if listview1.listitems(i).selected=true then
dim rs as new adodb.recordset
rs.cursorlocation=aduseclient
rs.open "select * from empdetail where empcode='" & listview1.selecteditem & _
"'",cn
if rs.recordcount>0 then
text1.text=rs!empcode
text2.text=rs!empname
text3.text=rs!empaddress
text4.text=rs!empdesignation
listview1.visible=false
text1.setfocus
rs.close
exit for
else
rs.close
msgbox("......",vbokonly,"")
end if
end if
next
end sub
|
|
|
|
|
|
Hi all,
Could you please help me, If i want to use vb.net to connect with scanner. How should I do? Could you pls provide the sample of it.
Thank so much
|
|
|
|
|
|
Hellow code friends,
I was searching 4 a while after my question but most of the time i find answers with a dataset.
I'm getting my data from a DB (without envolving a dataset).
So
My 4th column or column called opmerkingen is to small in width.
I just want to set my with to 80 or something when my datagridview is loaded.
Can anyone solve my problem in a simple way??
If you answer please do this with an example. there is nothing more clear then an ex...
Thx in advance
Greetings from a n00b
|
|
|
|
|
|
myDGV.Columns[3].Width=80;
or even maybe (once populated):
myDGV.AutoResizeColumns();
|
|
|
|
|
Thx mate
After populating : DataGridView1.AutoResizeColumns()
Did the trick...
greetz
|
|
|
|
|
|