Post your Vb.net Questions Here

Welcome. Please Login, Register, Or Activate! 
type your username and password to login
Date: November 23, 2009, 04:20 AM
431051 members and 298120 Topics
Latest Member: suedoh2006
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Programming  |  Post your Vb.net Questions Here
Pages: (1) (2) Go Down Send this topic Notify of replies
Author Topic: Post your Vb.net Questions Here  (Read 721 views)
luckyCO
Post your Vb.net Questions Here
« on: February 14, 2009, 10:34 AM »

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.
luckyCO
Re: Post your Vb.net Questions Here
« #1 on: February 14, 2009, 10:41 AM »

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




fatezy (m)
Re: Post your Vb.net Questions Here
« #2 on: February 14, 2009, 12:14 PM »

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
luckyCO
Re: Post your Vb.net Questions Here
« #3 on: February 14, 2009, 06:42 PM »

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.
luckyCO
Re: Post your Vb.net Questions Here
« #4 on: February 14, 2009, 06:51 PM »

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

fatezy (m)
Re: Post your Vb.net Questions Here
« #5 on: February 17, 2009, 01:44 AM »

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.
luckyCO
Re: Post your Vb.net Questions Here
« #6 on: February 18, 2009, 11:42 AM »

Quote from: fatezy on February 17, 2009, 01:44 AM
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
fatezy (m)
Re: Post your Vb.net Questions Here
« #7 on: February 18, 2009, 01:59 PM »

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
luckyCO
Re: Post your Vb.net Questions Here
« #8 on: February 19, 2009, 11:00 AM »

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
luckyCO
Re: Post your Vb.net Questions Here
« #9 on: February 20, 2009, 01:43 PM »

If it didnt help you, plz do let me know.
fatezy (m)
Re: Post your Vb.net Questions Here
« #10 on: February 20, 2009, 03:47 PM »

Thanks a lot. I'm yet to try it out. Would let you know au it all turns out
kheme (m)
help with sudoku puzzle generator
« #11 on: February 21, 2009, 04:04 PM »

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?

Code:
Public Class home
    Public rp = 0, arr(8, 8) As Integer, rsv(8, 8) 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 <= 8) 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 <= 8) 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 <= 8) 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!


* Untitled-1.jpg (74.83 KB, 285x310 )

* Untitled-2.jpg (75.68 KB, 285x310 )
luckyCO
Re: Post your Vb.net Questions Here
« #12 on: February 23, 2009, 10:50 AM »

I will test the code and let u know.
fatezy (m)
Re: Post your Vb.net Questions Here
« #13 on: February 26, 2009, 03:04 PM »

@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
fatezy (m)
Re: Post your Vb.net Questions Here
« #14 on: February 26, 2009, 03:05 PM »

@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
luckyCO
Re: Post your Vb.net Questions Here
« #15 on: February 26, 2009, 03:46 PM »

Quote from: fatezy on February 26, 2009, 03:05 PM
@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
fatezy (m)
Re: Post your Vb.net Questions Here
« #16 on: February 26, 2009, 05:22 PM »

ok then & thanks
luckyCO
Re: Post your Vb.net Questions Here
« #17 on: February 28, 2009, 12:08 PM »

You will modify the code to suit your 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 your 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")> <Category("Cyprosoft")> <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")> <Category("Cyprosoft")> <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")> <Category("Cyprosoft")> <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")> <Category("Cyprosoft")> <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")> <Category("Cyprosoft")> <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")> <Category("Cyprosoft")> <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")> <Category("Cyprosoft")> <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")> <Category("Cyprosoft")> <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")> <Category("Cyprosoft")> <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")> <Category("Cyprosoft")> <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 ")> <Category("Cyprosoft")> <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")> <Category("Cyprosoft")> <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 ")> <Category("Cyprosoft")> <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
luckyCO
Re: Post your Vb.net Questions Here
« #18 on: March 11, 2009, 12:49 PM »

Hello no more questions?
fatezy (m)
Re: Post your Vb.net Questions Here
« #19 on: March 16, 2009, 12:05 AM »

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. 
fatezy (m)
Re: Post your Vb.net Questions Here
« #20 on: March 17, 2009, 10:57 AM »

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
dammytosh
Re: Post your Vb.net Questions Here
« #21 on: March 17, 2009, 12:53 PM »

Quote from: fatezy on March 17, 2009, 10:57 AM
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
luckyCO
Re: Post your Vb.net Questions Here
« #22 on: March 27, 2009, 02:27 PM »

Quote from: dammytosh on March 17, 2009, 12:53 PM
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.
jacob05 (m)
Re: Post your Vb.net Questions Here
« #23 on: March 27, 2009, 03:03 PM »

@luckyOC
Any book or books you would recommed for beginner or intermediate in visual basic.
luckyCO
Re: Post your Vb.net Questions Here
« #24 on: March 28, 2009, 06:26 PM »

Quote from: soolari on March 28, 2009, 04:43 PM
I need 2 no more about vb plz anybdy can hlp me out i gat an assignment on it
Please post your questions I will answer it.
luckyCO
Re: Post your Vb.net Questions Here
« #25 on: March 28, 2009, 06:31 PM »

Quote from: jacob05 on March 27, 2009, 03:03 PM
@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
soolari (m)
Re: Post your Vb.net Questions Here
« #26 on: April 03, 2009, 07:59 AM »

Vb program to build a payroll of a company usin any variable
luckyCO
Re: Post your Vb.net Questions Here
« #27 on: April 03, 2009, 11:31 AM »

When do u need the code?
DEBOLABI
Re: Post your Vb.net Questions Here
« #28 on: April 09, 2009, 04:01 PM »

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
fatezy (m)
Re: Post your Vb.net Questions Here
« #30 on: May 09, 2009, 06:26 PM »

@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.
lekszile
Re: Post your Vb.net Questions Here
« #31 on: May 11, 2009, 10:07 AM »

will get back to you soon.
 A Compiler that enables Nigerians to Code In our local languages  Programmer Wanted For Mobile Solution  How to Upgrade to MySQL 5.0  Page 2
Pages: (1) (2) Go Up Send Topic to Friend by E-mail Reply 


Sections: Autos/Cars (2) Jobs/Vacancies (2) (3) Career Talk Education General(2) Politics Romance Computers Phones Travel
Sports Fashion Health Religion Celebrities TV/Movies (2) Music/Radio (2) Books Webmasters Programming

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa. See also: Nairalist Classified Ads
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.