Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,155,716 members, 7,827,593 topics. Date: Tuesday, 14 May 2024 at 02:04 PM

Post Ur Vb.net Questions Here - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Post Ur Vb.net Questions Here (3609 Views)

Post Your Ocpjp (scjp) Questions Here / Please Post All Your Java Programing Questions Here. / Post Ur Vb 6.0 Questions Here (2) (3) (4)

(1) (2) (Reply) (Go Down)

Post Ur Vb.net Questions Here by luckyCO(m): 10:34am On Feb 14, 2009
Post your Vb.Net Problems here. We can be of help to you.
You may visit www.pscode.com for code downloading on any subject.

Thanks are you post your vb.net Questions.
Re: Post Ur Vb.net Questions Here by luckyCO(m): 10:41am On Feb 14, 2009
If you have problems converting a vb6.0 code to vb.net here will best for.
I you are a beginner in C# and you know vb6.0 and would like to convert it to C#, here is also good for you.

I have maintained a thread on vb6.0, it would be of need that we learn dotnet such dat we will know the best tool suitable for out work.

Those using vb6.0, migrating to vb.net is going to be very easy but requires a careful study and analysis for you to understand how to do what which you know in vb6.0

For instand we use array to represent controls in vb6.0
text1(0).text
text1(1).text
etc

in dotnet that is no longer there, every object can exhibit an array property by using <Controlname>.controls and by associating it with
such control as below;

for each cto as control in me.controls
if typeof cto is textbox then
'your code
end if
next
which u know in vb6.0


Form collection has disappeared in vb.net
In vb6.0, you would write
for j=0 to forms.count-1
msgbox forms(j).name
next j

to display name of forms loaded

But dotnet 2005 next has taken it away, you can create the collection your self, maybe available in dotnet 2008 the it is in vb6.0

Printing has changed completely! We know of printer.print and datareport in vb6.0, but dotnet has enhanced so many things thereby bringing 'coreldraw' in dotnet.

The whole thing abt dotnet is, it is whole lot iof classes collectively called dotnet for u to use whenever you need them. It is sweet and simple.

Let us match together after having learn vb6.0 together
Re: Post Ur Vb.net Questions Here by fatezy(m): 12:14pm On Feb 14, 2009
Thank God for this thread. I'm about developing a windows based database application & quite sure i'll get stuck at some point. Hope i'll get answers here
Re: Post Ur Vb.net Questions Here by luckyCO(m): 6:42pm On Feb 14, 2009
Please feel free and let me know your problems are, you can contact me incase you think dat I have delayed in responding to your immediate question. 08036025235

Thanks and God bless.
Re: Post Ur Vb.net Questions Here by luckyCO(m): 6:51pm On Feb 14, 2009
Before you start to develop any application check the following;

1. First think about the problem you are about to solve. If you dont understand the problem plz dont go ahead to develope the solution.
2. Study and choose right tools, there are programs you can easily developed with one (vb6.0,vb.net,c#,C++) to the other.
3. Study and Choose right database,Access,MySQL,SQL Server,Oracle etc
4. Asseble and organized your codes in classes to be be easily used by other classes.
5. Avoid copy and paste type of programming rather use Classes,Functions,Procedures etc. depends on the language.
6. If you are using SQL Server,MySQL,etc try much to harness the use of Trigger,Views,Store Procedures etc
7. Then use GOOD variable naming system
eg. Dim DailyExpenses as Currency,StaffName as string
etc
Re: Post Ur Vb.net Questions Here by fatezy(m): 1:44am On Feb 17, 2009
I have two slight problems:
1. How can i pass a variable btwn forms. In a login form i have username declared & want to pass the value to another variable username in main menu form.
2. Store the value of a cell in a datagrid into a variable name by doubleclicking on the cell.
I'll aspecicte a response asap. Thanks & more to come.
Re: Post Ur Vb.net Questions Here by luckyCO(m): 11:42am On Feb 18, 2009
fatezy:

I have two slight problems:
1. How can i pass a variable btwn forms. In a login form i have username declared & want to pass the value to another variable username in main menu form.
2. Store the value of a cell in a datagrid into a variable name by doubleclicking on the cell.
I'll aspecicte a response asap. Thanks & more to come.

You can do in 2 diff ways if you are using vb.net or c#
Code Vb.net

In main form enter the code below
dim _Username as string =""
Property UserName as string
get
return _Username
end get

set
_username=value
end set
end property

From the reference form

,
dim frmMain as new mainForm
frmmain.username=textbox1.text
frmmain.show
,

, can be any procedure

Will ansqwer the second question, I need to know he precudure aguement.
Thanks
Re: Post Ur Vb.net Questions Here by fatezy(m): 1:59pm On Feb 18, 2009
Thanks for answering d first. For the 2nd may be i should explain more.
I have a datagrid called customers dat holds a table from database. What I intend to do is that once a cell is double clicked, the value in that cell should be stored into a variable named selectedValue. Hope this helps
Re: Post Ur Vb.net Questions Here by luckyCO(m): 11:00am On Feb 19, 2009
Add button === button1
datagridview===grd

Paste the code in form1 class body

Public Class Form1

Dim SelectedValue as string =""

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frmM As New frmmain
frmM.username = TextBox1.Text
frmM.Show()
End Sub



Private Sub grd_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grd.MouseDoubleClick

SelectedValue =grd.CurrentCell.Value

MsgBox(grd.CurrentCell.Value)
End Sub
End Class



'Second form to tranfer variable
Public Class frmmain

Dim _Username As String = ""
Property username() As String
Get
Return _Username
End Get
Set(ByVal value As String)
_Username = value
End Set

End Property

Private Sub frmmain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MsgBox(_Username)
End Sub
End Class
Re: Post Ur Vb.net Questions Here by luckyCO(m): 1:43pm On Feb 20, 2009
If it didnt help you, plz do let me know.
Re: Post Ur Vb.net Questions Here by fatezy(m): 3:47pm On Feb 20, 2009
Thanks a lot. I'm yet to try it out. Would let you know au it all turns out
Re: Post Ur Vb.net Questions Here by kheme(m): 4:04pm On Feb 21, 2009
hi. i'm trying to write a sudoku puzzle generator with vb.net but my algorithm seems correct, but runs out of numbers at some stages while generating the puzzle. can anyone look into ma code and see why?

Public Class home
Public rp = 0, arr(8, cool As Integer, rsv(8, cool As List(Of Integer), ax(2, 2)

Public Function sot(ByRef ar As Array)
Dim o, p, q, r
For o = 0 To 8
If (ar(o) = Nothing) Then
For p = o To 1 Step -1
q = ar(p)
r = ar(p - 1)
ar(p) = r
ar(p - 1) = q
Next
End If
Next
Return Nothing
End Function

Public Function rnd(ByVal x As Integer, ByVal y As Integer)
Dim r1 = Nothing, rd As New Random
For a As Integer = 0 To 8
If (arr(x, a) <> 0 And rsv(x, y).IndexOf(arr(x, a)) <> -1) Then
rsv(x, y).RemoveAt(rsv(x, y).IndexOf(arr(x, a)))
End If

If (arr(a, y) <> 0 And rsv(x, y).IndexOf(arr(a, y)) <> -1) Then
rsv(x, y).RemoveAt(rsv(x, y).IndexOf(arr(a, y)))
End If
Next

If (x >= 0 And x <= 2 And y >= 0 And y <= 2) Then
For a1 As Integer = 0 To 2
For b1 As Integer = 0 To 2
If (arr(a1, b1) <> Nothing And rsv(x, y).IndexOf(arr(a1, b1)) <> -1) Then
rsv(x, y).RemoveAt(rsv(x, y).IndexOf(arr(a1, b1)))
End If
Next
Next
End If
If (x >= 0 And x <= 2 And y >= 3 And y <= 5) Then
For a1 As Integer = 0 To 2
For b1 As Integer = 3 To 5
If (arr(a1, b1) <> Nothing And rsv(x, y).IndexOf(arr(a1, b1)) <> -1) Then
rsv(x, y).RemoveAt(rsv(x, y).IndexOf(arr(a1, b1)))
End If
Next
Next
End If
If (x >= 0 And x <= 2 And y >= 6 And y <= cool Then
For a1 As Integer = 0 To 2
For b1 As Integer = 6 To 8
If (arr(a1, b1) <> Nothing And rsv(x, y).IndexOf(arr(a1, b1)) <> -1) Then
rsv(x, y).RemoveAt(rsv(x, y).IndexOf(arr(a1, b1)))
End If
Next
Next
End If

If (x >= 3 And x <= 5 And y >= 0 And y <= 2) Then
For a1 As Integer = 3 To 5
For b1 As Integer = 0 To 2
If (arr(a1, b1) <> Nothing And rsv(x, y).IndexOf(arr(a1, b1)) <> -1) Then
rsv(x, y).RemoveAt(rsv(x, y).IndexOf(arr(a1, b1)))
End If
Next
Next
End If
If (x >= 3 And x <= 5 And y >= 3 And y <= 5) Then
For a1 As Integer = 3 To 5
For b1 As Integer = 3 To 5
If (arr(a1, b1) <> Nothing And rsv(x, y).IndexOf(arr(a1, b1)) <> -1) Then
rsv(x, y).RemoveAt(rsv(x, y).IndexOf(arr(a1, b1)))
End If
Next
Next
End If
If (x >= 3 And x <= 5 And y >= 6 And y <= cool Then
For a1 As Integer = 3 To 5
For b1 As Integer = 6 To 8
If (arr(a1, b1) <> Nothing And rsv(x, y).IndexOf(arr(a1, b1)) <> -1) Then
rsv(x, y).RemoveAt(rsv(x, y).IndexOf(arr(a1, b1)))
End If
Next
Next
End If

If (x >= 6 And x <= 8 And y >= 0 And y <= 2) Then
For a1 As Integer = 6 To 8
For b1 As Integer = 0 To 2
If (arr(a1, b1) <> Nothing And rsv(x, y).IndexOf(arr(a1, b1)) <> -1) Then
rsv(x, y).RemoveAt(rsv(x, y).IndexOf(arr(a1, b1)))
End If
Next
Next
End If
If (x >= 6 And x <= 8 And y >= 3 And y <= 5) Then
For a1 As Integer = 6 To 8
For b1 As Integer = 3 To 5
If (arr(a1, b1) <> Nothing And rsv(x, y).IndexOf(arr(a1, b1)) <> -1) Then
rsv(x, y).RemoveAt(rsv(x, y).IndexOf(arr(a1, b1)))
End If
Next
Next
End If
If (x >= 6 And x <= 8 And y >= 6 And y <= cool Then
For a1 As Integer = 6 To 8
For b1 As Integer = 6 To 8
If (arr(a1, b1) <> Nothing And rsv(x, y).IndexOf(arr(a1, b1)) <> -1) Then
rsv(x, y).RemoveAt(rsv(x, y).IndexOf(arr(a1, b1)))
End If
Next
Next
End If

Try
arr(x, y) = rsv(x, y)(rd.Next(0, rsv(x, y).Count))
Catch ex As Exception

End Try
Return Nothing
End Function

Private Sub home_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a = 0, b = 0, c = 0, n
For a = 0 To 8
For b = 0 To 8
n = "s" & a & b
rsv(a, b) = New List(Of Integer)
For c = 1 To 9
rsv(a, b).Add(c)
Next
rnd(a, b)
Panel2.Controls.Item(n).text = arr(a, b)
Next
Next

End Sub

Private Sub RefreshToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshToolStripMenuItem.Click
rp = 0
Array.Clear(arr, 0, 81)
home_Load(Nothing, Nothing)
End Sub
End Class


i've attached screen shots, the "0" in the puzzle are the places where the algorithm runs out of numbers to put cos the next number to put cannot be placed there due to the rules of sudoku. i need help guys!

Re: Post Ur Vb.net Questions Here by luckyCO(m): 10:50am On Feb 23, 2009
I will test the code and let u know.
Re: Post Ur Vb.net Questions Here by fatezy(m): 3:04pm On Feb 26, 2009
@lucky, thanks very much for d help thus far. I've almost finished d project just remaining codes for printing.
1. How do I print the contents of a datagridview using a deskjet printer? and
2. I want to print some details in a specific format like- printin textboxName, listviewProducts, listviewTypes, textboxAmount using d type of printers used for POS(pls whats d name?) in the format:
textboxName
contents of listview side by side
textboxAmount.
I'm awaitin your reply. Thanks
Re: Post Ur Vb.net Questions Here by fatezy(m): 3:05pm On Feb 26, 2009
@lucky, thanks very much for d help thus far. I've almost finished d project just remaining codes for printing.
1. How do I print the contents of a datagridview using a deskjet printer? and
2. I want to print some details in a specific format like- printin textboxName, listviewProducts, listviewTypes, textboxAmount using d type of printers used for POS(pls whats d name?) in the format:
textboxName
contents of listview side by side
textboxAmount.
I'm awaitin your reply. Thanks
Re: Post Ur Vb.net Questions Here by luckyCO(m): 3:46pm On Feb 26, 2009
fatezy:

@lucky, thanks very much for d help thus far. I've almost finished d project just remaining codes for printing.
1. How do I print the contents of a datagridview using a deskjet printer? and
2. I want to print some details in a specific format like- printin textboxName, listviewProducts, listviewTypes, textboxAmount using d type of printers used for POS(pls whats d name?) in the format:
textboxName
contents of listview side by side
textboxAmount.
I'm awaitin your reply. Thanks

It is a very long code. I will post it for u to modify it.
Am a bit rushing somewhere , but will definitely post it to u
Re: Post Ur Vb.net Questions Here by fatezy(m): 5:22pm On Feb 26, 2009
ok then & thanks
Re: Post Ur Vb.net Questions Here by luckyCO(m): 12:08pm On Feb 28, 2009
You will modify the code to suit ur need.
I dont have time to run the program to declare all the required variables, hope u can do that?

U need PrintDocument1 control among others

Change me. to the name of ur datagridview.
Remove any variable decalaration that doesnt make sense to u.
I designed a user control which I supplied diff colors to achive ahwta I need.


#Region "Printing of the grid goes here and its settings"
Private oStringFormat As StringFormat
Private oStringFormatComboBox As StringFormat
Private oButton As System.Windows.Forms.Button
Private oCheckbox As System.Windows.Forms.CheckBox
Private oComboBox As System.Windows.Forms.ComboBox

Private nTotalWidth As Int16
Private nRowPos As Int16
Private NewPage As Boolean
Private nPageNo As Int16
Private Header As String = ""

Dim ok As Boolean = True
Dim oColumnLefts As New ArrayList
Dim oColumnWidths As New ArrayList
Dim oColumnTypes As New ArrayList
Dim _FillGridColorHeader As Color
Dim _GridHeaderPen As Color
Dim _BodyGridPen As Color
Dim _PrintDate, _UseMyCaption, _RecieptFormat As Boolean
Dim _captionFont As Font
Dim _HeaderFont As Font
Dim _GridCellFont As Font

Enum OrientationDefault As Integer
DefaultPortrait = 0
DefaultLandScape = 1
End Enum
Dim _DefaultOrientation As OrientationDefault = OrientationDefault.DefaultPortrait

<Description("Determines the default page orientation to be be used"wink> <Category("Cyprosoft"wink> <DefaultValue(0)> _
Property DefaultOrientation() As OrientationDefault
Get
Return _DefaultOrientation
End Get
Set(ByVal value As OrientationDefault)
_DefaultOrientation = value
If _DefaultOrientation = OrientationDefault.DefaultLandScape Then
ok = False
Else
ok = True
End If
End Set
End Property
<Description("For print Preview options. Fill the backgroup of the header"wink> <Category("Cyprosoft"wink> <DefaultValue(0)> _
Property FillGridColorHeader() As Color
Get
Return _FillGridColorHeader
End Get
Set(ByVal value As Color)
_FillGridColorHeader = value
End Set
End Property
<Description("For print Preview options. Fill the backgroup pen brush header"wink> <Category("Cyprosoft"wink> <DefaultValue(0)> _
Property GridHeaderPen() As Color
Get
Return _GridHeaderPen
End Get
Set(ByVal value As Color)
_GridHeaderPen = value
End Set
End Property
<Description("For print Preview options. Fille the body pen"wink> <Category("Cyprosoft"wink> <DefaultValue(0)> _
Property BodyGridPens() As Color
Get
Return _BodyGridPen

End Get
Set(ByVal value As Color)
_BodyGridPen = value
End Set
End Property


<Description("Caption for the report title"wink> <Category("Cyprosoft"wink> <DefaultValue(0)> _
Property Caption() As String
Get
Return Header
End Get
Set(ByVal value As String)
Header = value
End Set
End Property
Dim _CaptionColor As Color
<Description("Caption for the report title"wink> <Category("Cyprosoft"wink> <DefaultValue(0)> _
Property CaptionColor() As Color
Get
Return _CaptionColor
End Get
Set(ByVal value As Color)
_CaptionColor = value
End Set
End Property

<Description("Change format options to reciept type"wink> <Category("Cyprosoft"wink> <DefaultValue(0)> _
Property RecieptFormat() As Boolean
Get
Return _RecieptFormat
End Get
Set(ByVal value As Boolean)
_RecieptFormat = value
End Set
End Property

<Description("Determine Whether Advanced setting configuration will be used"wink> <Category("Cyprosoft"wink> <DefaultValue(0)> _
Property UseMyCaption() As Boolean
Get
Return _UseMyCaption
End Get
Set(ByVal value As Boolean)
_UseMyCaption = value
End Set
End Property

<Description("For print Preview options. Fille the backgroup of the header"wink> <Category("Cyprosoft"wink> <DefaultValue(0)> _
Property PrintDate() As Boolean
Get
Return _PrintDate
End Get
Set(ByVal value As Boolean)
_PrintDate = value
End Set
End Property
<Description("Choose font for Caption"wink> <Category("Cyprosoft"wink> <DefaultValue(0)> _
Property CaptionFont() As Font
Get
Return _captionFont
End Get
Set(ByVal value As Font)
_captionFont = value
End Set
End Property

<Description("Choose font for hearder "wink> <Category("Cyprosoft"wink> <DefaultValue(0)> _
Property HeaderFont() As Font
Get
Return _HeaderFont
End Get
Set(ByVal value As Font)
_HeaderFont = value
End Set
End Property
Dim _LocationOfPageNo As Int16 = 36
<Description("Location of page Number in the grid"wink> <Category("Cyprosoft"wink> <DefaultValue(0)> _
Property LocationOfPageNo() As Int16
Get
Return _LocationOfPageNo
End Get
Set(ByVal value As Int16)
_LocationOfPageNo = value
End Set
End Property

<Description("Choose font for Cell "wink> <Category("Cyprosoft"wink> <DefaultValue(0)> _
Property GridCellFont() As Font
Get
Return _GridCellFont
End Get
Set(ByVal value As Font)
_GridCellFont = value
End Set
End Property
Dim FirstEntry As Int16 = 0
Dim PageNo As Int32 = 0
Private Sub DrawFooter(ByVal e As System.Drawing.Printing.PrintPageEventArgs, ByVal RowsPerPage As Int32)
If RowsPerPage = 0 Then Exit Sub


Try


FirstEntry += 1

If FirstEntry < 2 Then
PageNo = (Math.Ceiling(Me.Rows.Count / RowsPerPage).ToString)

Dim Confirm As Int16 = Math.Truncate(e.MarginBounds.Height / CellHight)


If Me.Rows.Count < (Confirm - 10) And Val(PageNo) = 2 Then
PageNo = "1"
End If

End If


'Draw header is working here



Dim sPageNo As String = nPageNo.ToString + " of " + PageNo.ToString
' Right Align - User Name
' e.Graphics.DrawString(sUserName, me.Font, Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width - e.Graphics.MeasureString(sPageNo, me.Font, e.MarginBounds.Width).Width), e.MarginBounds.Top + e.MarginBounds.Height + _LocationOfPageNo)

' Left Align - Date/Time
If _PrintDate = True Then
e.Graphics.DrawString(Now.ToLongDateString + " " + Now.ToShortTimeString, Me.Font, Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top + e.MarginBounds.Height + _LocationOfPageNo)
End If

' Center - Page No. Info
e.Graphics.DrawString(sPageNo, Me.Font, Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width - e.Graphics.MeasureString(sPageNo, Me.Font, e.MarginBounds.Width).Width) / 2, e.MarginBounds.Top + e.MarginBounds.Height + _LocationOfPageNo)
Catch ex As Exception

End Try

End Sub

Dim PrinterDialogOpen As Boolean = False

Public Sub PrintPreview()
Try

If frm2 IsNot Nothing And _UseMyCaption = False Then
_PrintDate = frm2.checkPrtDate.Checked
If frm2.txtCaption.Text <> "" Then Header = frm2.txtCaption.Text

_CaptionColor = frm2.lblCaptionColor.BackColor
_GridHeaderPen = frm2.lblGridHeaderColor.BackColor
_FillGridColorHeader = frm2.lblHearderBgdColor.BackColor
_BodyGridPen = frm2.lblGridColor.BackColor

_captionFont = frm2.txtC.Font
_HeaderFont = frm2.txtH.Font
_GridCellFont = frm2.txtG.Font
End If



If PrinterDialogOpen = False Then
PrintDocument1.DefaultPageSettings = PageSetupDialog1.PageSettings

Else

PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings

End If


If PageSetupOpen = False Then
PrintDocument1.DefaultPageSettings.Landscape = False
ok = False
End If


PrintPreviewDialog1.Document = PrintDocument1
PrintDialog1.Document = PrintDocument1


' PrintDocument1.DefaultPageSettings = PageSetupDialog1.PageSettings

PrintPreviewDialog1.ShowDialog()


ok = PrintDocument1.DefaultPageSettings.Landscape



oColumnLefts.Clear()
oColumnWidths.Clear()
oColumnTypes.Clear()

frm2.Dispose()

Catch ex As Exception

MsgBox(ex.Message)
Finally
oColumnLefts.Clear()
oColumnWidths.Clear()
oColumnTypes.Clear()
End Try



End Sub
Dim PageSetupOpen As Boolean = False

Public Sub PageSetup()
Try
'Dim PrintDocument1 As New Printing.PrintDocument

PageSetupDialog1.Document = PrintDocument1
PageSetupDialog1.ShowDialog()
PrintDocument1.DefaultPageSettings = PageSetupDialog1.PageSettings

ok = PageSetupDialog1.PageSettings.Landscape

PageSetupOpen = True
Catch ex As Exception

End Try

End Sub

Public Sub PrinterSetup()
Try

PrintDialog1.Document = PrintDocument1
PrintDialog1.AllowSomePages = True
PrintDialog1.AllowCurrentPage = True
PrintDialog1.AllowSelection = True
PrintDialog1.AllowPrintToFile = True
PrintDialog1.ShowDialog()
PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings
PrinterDialogOpen = True
Catch ex As Exception

End Try

End Sub

#End Region

Private Sub PrintDocument1_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.BeginPrint
Try
counterPages = 0

oStringFormat = New StringFormat
oStringFormat.Alignment = StringAlignment.Near
oStringFormat.LineAlignment = StringAlignment.Center
oStringFormat.Trimming = StringTrimming.EllipsisCharacter

oStringFormatComboBox = New StringFormat
oStringFormatComboBox.LineAlignment = StringAlignment.Center
oStringFormatComboBox.FormatFlags = StringFormatFlags.NoWrap
oStringFormatComboBox.Trimming = StringTrimming.EllipsisCharacter

oButton = New System.Windows.Forms.Button
oCheckbox = New System.Windows.Forms.CheckBox
oComboBox = New System.Windows.Forms.ComboBox

nTotalWidth = 0


For Each oColumn As DataGridViewColumn In Me.Columns

nTotalWidth += oColumn.Width

Next

nPageNo = 1
NewPage = True
nRowPos = 0
Catch ex As Exception

End Try

End Sub

Private Sub PrintDocument1_EndPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.EndPrint
FirstEntry = 0
nPageNo = 1

End Sub
Dim CellHight As Int16 = 1

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Try

CellHight = 1
Static nHeight As Int16
Dim holVal As Int16 = 0
Dim ValHol As Int16 = 0
Dim nWidth, i, nRowsPerPage As Int16
Dim nTop As Int16 = e.MarginBounds.Top
Dim nLeft As Int16 = e.MarginBounds.Left

If nPageNo = 1 Then

For Each oColumn As DataGridViewColumn In Me.Columns()

nWidth = CType(Math.Floor(oColumn.Width / nTotalWidth * nTotalWidth * (e.MarginBounds.Width / nTotalWidth)), Int16)

nHeight = e.Graphics.MeasureString(oColumn.HeaderText, oColumn.InheritedStyle.Font, nWidth).Height + 11



oColumnLefts.Add(nLeft)
oColumnWidths.Add(nWidth)
oColumnTypes.Add(oColumn.GetType)
nLeft += nWidth

Next

End If

Do While nRowPos < Me.Rows.Count

Dim oRow As DataGridViewRow = Me.Rows(nRowPos)

If nTop + nHeight >= e.MarginBounds.Height + e.MarginBounds.Top Then

DrawFooter(e, nRowsPerPage)
NewPage = True
nPageNo += 1
e.HasMorePages = True
Exit Sub

Else

If NewPage Then

' Draw Header


Dim _CaptionColorHeader As New SolidBrush(_CaptionColor)

If _captionFont Is Nothing Then
_captionFont = New System.Drawing.Font(Me.Font, FontStyle.Bold)
End If


e.Graphics.DrawString(Header, _captionFont, _CaptionColorHeader, (e.MarginBounds.Left + e.MarginBounds.Right) / 2 - e.Graphics.MeasureString(Header, New System.Drawing.Font(Me.Font, FontStyle.Bold), e.MarginBounds.Width).Width / 2, e.MarginBounds.Top - e.Graphics.MeasureString(Header, New System.Drawing.Font(Me.Font, FontStyle.Bold), e.MarginBounds.Width).Height - 13)
' Draw Columns
nTop = e.MarginBounds.Top
i = 0

For Each oColumn As DataGridViewColumn In Me.Columns()

If _HeaderFont Is Nothing Then
_HeaderFont = oColumn.InheritedStyle.Font
End If

'column headers are painted on the three lines below

Dim _cGridHeaderPen As New Pen(_GridHeaderPen)


e.Graphics.FillRectangle(New SolidBrush(_FillGridColorHeader), New System.Drawing.Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight))
e.Graphics.DrawRectangle(_cGridHeaderPen, New _
System.Drawing.Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight))
e.Graphics.DrawString(oColumn.HeaderText, _HeaderFont, New _
SolidBrush(oColumn.InheritedStyle.ForeColor), New _
RectangleF(oColumnLefts(i), nTop, oColumnWidths(i), nHeight), oStringFormat)
i += 1

Next
NewPage = False

End If

nTop += nHeight
i = 0


For Each oCell As DataGridViewCell In oRow.Cells

If _GridCellFont Is Nothing Then
_GridCellFont = oCell.InheritedStyle.Font
End If

Dim _cBodyGridPen As New Pen(_BodyGridPen)

If oColumnTypes(i) Is GetType(DataGridViewTextBoxColumn) OrElse oColumnTypes(i) Is GetType(DataGridViewLinkColumn) Then

If _UseDataGridColorInreport = True Then e.Graphics.FillRectangle(New SolidBrush(Me.Rows(nRowPos).Cells(i).InheritedStyle.BackColor), New System.Drawing.Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight))


Try
e.Graphics.DrawString(oCell.Value.ToString, _GridCellFont, New SolidBrush(oCell.InheritedStyle.ForeColor), _
New RectangleF(oColumnLefts(i), nTop, oColumnWidths(i), nHeight), oStringFormat)
Catch ex As Exception
e.Graphics.DrawString("", _GridCellFont, New SolidBrush(Color.White), _
New RectangleF(oColumnLefts(i), nTop, oColumnWidths(i), nHeight), oStringFormat)
End Try



ElseIf oColumnTypes(i) Is _
GetType(DataGridViewButtonColumn) Then

If _UseDataGridColorInreport = True Then e.Graphics.FillRectangle(New SolidBrush(Me.Rows(nRowPos).Cells(i).InheritedStyle.BackColor), New System.Drawing.Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight))

oButton.Text = oCell.Value.ToString
oButton.Size = New Size(oColumnWidths(i), nHeight)
Dim oBitmap As New Bitmap(oButton.Width, oButton.Height)
oButton.DrawToBitmap(oBitmap, New System.Drawing.Rectangle(0, 0, oBitmap.Width, oBitmap.Height))
e.Graphics.DrawImage(oBitmap, New System.Drawing.Point(oColumnLefts(i), nTop))

ElseIf oColumnTypes(i) Is GetType(DataGridViewCheckBoxColumn) Then
If _UseDataGridColorInreport = True Then e.Graphics.FillRectangle(New SolidBrush(Me.Rows(nRowPos).Cells(i).InheritedStyle.BackColor), New System.Drawing.Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight))
oCheckbox.Size = New Size(14, 14)
oCheckbox.Checked = CType(oCell.Value, Boolean)
Dim oBitmap As New Bitmap(oColumnWidths(i), nHeight)
Dim oTempGraphics As Graphics = Graphics.FromImage(oBitmap)
oTempGraphics.FillRectangle(Brushes.White, New _
System.Drawing.Rectangle(0, 0, oBitmap.Width, oBitmap.Height))
oCheckbox.DrawToBitmap(oBitmap, New _
System.Drawing.Rectangle(CType((oBitmap.Width - oCheckbox.Width) / 2, _
Int32), CType((oBitmap.Height - oCheckbox.Height) / 2, Int32), oCheckbox.Width, oCheckbox.Height))
e.Graphics.DrawImage(oBitmap, New System.Drawing.Point(oColumnLefts(i), nTop))

ElseIf oColumnTypes(i) Is GetType(DataGridViewComboBoxColumn) Then
If _UseDataGridColorInreport = True Then e.Graphics.FillRectangle(New SolidBrush(Me.Rows(nRowPos).Cells(i).InheritedStyle.BackColor), New System.Drawing.Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight))
oComboBox.Size = New Size(oColumnWidths(i), nHeight)
Dim oBitmap As New Bitmap(oComboBox.Width, oComboBox.Height)
oComboBox.DrawToBitmap(oBitmap, New System.Drawing.Rectangle(0, 0, oBitmap.Width, oBitmap.Height))
e.Graphics.DrawImage(oBitmap, New System.Drawing.Point(oColumnLefts(i), nTop))
e.Graphics.DrawString(oCell.Value.ToString, oCell.InheritedStyle.Font, New _
SolidBrush(oCell.InheritedStyle.ForeColor), _
New RectangleF(oColumnLefts(i) + 1, nTop, oColumnWidths(i) - 16, nHeight), oStringFormatComboBox)

ElseIf oColumnTypes(i) Is _
GetType(DataGridViewImageColumn) Then
If _UseDataGridColorInreport = True Then e.Graphics.FillRectangle(New SolidBrush(Me.Rows(nRowPos).Cells(i).InheritedStyle.BackColor), New System.Drawing.Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight))
Dim oCellSize As System.Drawing.Rectangle = New _
System.Drawing.Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight)
Dim oImageSize As Size = CType(oCell.Value, Image).Size

e.Graphics.DrawImage(oCell.Value, New _
System.Drawing.Rectangle(oColumnLefts(i) + CType(((oCellSize.Width - oImageSize.Width) / 2), Int32), nTop + CType(((oCellSize.Height - oImageSize.Height) / 2), Int32), CType(oCell.Value, Image).Width, CType(oCell.Value, Image).Height))

End If


'This draws line on the form making it looks as grid

e.Graphics.DrawRectangle(_cBodyGridPen, New _
System.Drawing.Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight))

CellHight = Me.Rows(nRowPos).Cells(i).Size.Height
i += 1

Next

End If

nRowPos += 1
nRowsPerPage += 1

Loop

DrawFooter(e, nRowsPerPage)

e.HasMorePages = False
Catch ex As Exception
MsgBox(ex.Message)
End Try

End Sub

I know u are a good programmer, plz do arrange it to help u out, thanks
Re: Post Ur Vb.net Questions Here by luckyCO(m): 12:49pm On Mar 11, 2009
Hello no more questions?
Re: Post Ur Vb.net Questions Here by fatezy(m): 12:05am On Mar 16, 2009
Sorry got to go offline for sometime, I've still got a lil question.
I have a button called CHOOSE PIC. I want it to be able to allow me select a picture from d syst i.e show me all d systems documents and then select a picture and then Store it in an image box PICBOX. I'll like it to work like that of windows account manager for example where you can select a picture for your account. I hope this can be done. Your quick response would be appreciated, Its d last bit of my project. Thanks.
Re: Post Ur Vb.net Questions Here by fatezy(m): 10:57am On Mar 17, 2009
I found out to do it using the openfiledialog. Thanks for the help thus far.
I copied the .exe file for my project on to the target system & it worked but when I want to install the setup file I created for it, it says .Net framework is not available. Is there any way to go around this or I have to install visual studio on the target system. Thanks for the help
Re: Post Ur Vb.net Questions Here by dammytosh: 12:53pm On Mar 17, 2009
fatezy:

I found out to do it using the openfiledialog. Thanks for the help thus far.
I copied the .exe file for my project on to the target system & it worked but when I want to install the setup file I created for it, it says .Net framework is not available. Is there any way to go around this or I have to install visual studio on the target system. Thanks for the help

No ! you dont need to install visual studio on the target system, all u need is to install the version of the dotnet framework you used during development on the target machine.
u can download the framework for free on microsoft's site.

i hope that helps
Re: Post Ur Vb.net Questions Here by luckyCO(m): 2:27pm On Mar 27, 2009
dammytosh:

No ! you dont need to install visual studio on the target system, all u need is to install the version of the dotnet framework you used during development on the target machine.
u can download the framework for free on microsoft's site.

i hope that helps

You are Correct.
Thank you for that.
Re: Post Ur Vb.net Questions Here by jacob05(m): 3:03pm On Mar 27, 2009
@luckyOC
Any book or books you would recommed for beginner or intermediate in visual basic.
Re: Post Ur Vb.net Questions Here by luckyCO(m): 6:26pm On Mar 28, 2009
soolari:

I need 2 no more about vb plz anybdy can hlp me out i gat an assignment on it
Please post ur questions I will answer it.
Re: Post Ur Vb.net Questions Here by luckyCO(m): 6:31pm On Mar 28, 2009
jacob05:

@luckyOC
Any book or books you would recommed for beginner or intermediate in visual basic.

Please visit www.4shared.com and type any book you like and see what you will get.
Thanks
Re: Post Ur Vb.net Questions Here by soolari(m): 7:59am On Apr 03, 2009
Vb program to build a payroll of a company usin any variable
Re: Post Ur Vb.net Questions Here by luckyCO(m): 11:31am On Apr 03, 2009
When do u need the code?
Re: Post Ur Vb.net Questions Here by DEBOLABI: 4:01pm On Apr 09, 2009
please any body in the house, i dont know much about VB at all, just love to be a programmer. if you can train me very well please call 08027656939
Re: Post Ur Vb.net Questions Here by fatezy(m): 6:26pm On May 09, 2009
@lucky, Its been long hope u aight! I need a lil help and hope u can b of assistance,
I would like a form to load immediately at system startup, Its to provide a custom login, The problems I have are -
1. Code to make the form load immediate u put on d system
2. To prevent closure of d form using alt + f4.
Thanks 4 your help.
Re: Post Ur Vb.net Questions Here by lekszile: 10:07am On May 11, 2009
will get back to you soon.

(1) (2) (Reply)

Come Here To Learn Java In Pidgin / . / Need Help On This Basic Php

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 108
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.