|
Firstly you have to put a dataGrid inside your form, than paste the code below inside your Form1.vb page
here is the simple datagrid code:
-----------------------------------
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Friend WithEvents UserControl11 As maskedTextBox.MaskeliTextBox
Friend WithEvents reportDocument1 As CrystalDecisions.CrystalReports.Engine.ReportDocument
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.DataGrid1 = New System.Windows.Forms.DataGrid
Me.reportDocument1 = New CrystalDecisions.CrystalReports.Engine.ReportDocument
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(480, 48)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 0
Me.Button1.Text = "Sorgula"
'
'DataGrid1
'
Me.DataGrid1.DataMember = ""
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(24, 184)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.Size = New System.Drawing.Size(648, 224)
Me.DataGrid1.TabIndex = 1
'
'reportDocument1
'
Me.reportDocument1.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.DefaultPaperOrientation
Me.reportDocument1.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize
Me.reportDocument1.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Upper
Me.reportDocument1.PrintOptions.PrinterDuplex = CrystalDecisions.Shared.PrinterDuplex.Default
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(704, 430)
Me.Controls.Add(Me.DataGrid1)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As New SqlConnection("Server=.;Database=pubs;uid=sa;pwd=;")
conn.Open()
Dim comm As New SqlCommand("Select * From Employee")
Dim adp As SqlDataAdapter = New SqlDataAdapter(comm.CommandText, conn)
Dim ds As New DataSet
adp.Fill(ds)
DataGrid1.DataSource = ds
End Sub
End Class
--junior coder--
|
|
|
|
|
Hye guys
I have used MSDN help to create one remoting application and it runs fine. Now I have build my application and having some problems in it
My remote class is Project1.class1 which returns different variables like dataset,datatable etc,.... when I compile the project through Vbc.exe it gives error but it works fine with build from menu.. I have seen many examples and every one compiles through Vbc...
Why we need to compile project through vbc ??? why not build option ???
Now in hosting application. (note: My remote class is Project1.Class1)
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown
="" mode="Singleton" type="RemotableType, RemotableType" objecturi="RemotableType.rem">
<channels>
<channel ref="http" port="8989">
in this config file in wellknow tag what should I put against type and objectURi..
Your support will be highly appreciated... + if any one knows any document for client configuration with each and every aspects + about Vbc do let me know
|
|
|
|
|
Hi everybody
Does anyone know how can I design my report in landscape mode. I don't know how can I enlarge the margins of my Report.
Thanks in Advance
|
|
|
|
|
If you're using it inside the .NET IDE, [right-click --> choose designer --> Printer setup --> change to landscape].
|
|
|
|
|
hi to you all,
i need to search group of objects in an arraylist and the only reference i have is their IDs,
is there a fast way to search those objects?
iterating through the arraylist again and again would be quite slow...
thanks in advance,
cheers!
Fuel2Run
|
|
|
|
|
|
I think it's to late to use a different collection, i'll iterate.
thanks anyway!
Cheers
Fuel2Run
|
|
|
|
|
how can i create a new table via sql command in vb recall my database is SQL Server 2000
|
|
|
|
|
|
i have two forms. FORM1 and FORM2. Form1 has a datagrid with columns that reads from an xml file. form2 has 4 textboxes. how do I get these textboxes writen to the xml file so they will show in the datagrid on form1. My datagrid has 4 columns.
|
|
|
|
|
Look into the system.IO namespace.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am building a vb.net app that needs to be able to receive notification if a link is clicked in IE. specificly a speceal link like <'a href="test://testtesttest">Test
where the protocol is actually the function that gets fired in my app.
please help
Thanks in advance
Tim
|
|
|
|
|
how can i create a relationship beween scanner and a form in vb
|
|
|
|
|
Buy them both movie tickets, I guess.....
What do you want to do - get the form to always show what's on the scanner ? There's no way for the code to know that the contents of the scanner have changed. Do you have TWAIN drivers in VB.NET already ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
i want to scan a paper via a vb form and save it in a database therefore vb from must be enbale to detect if scanner is connect to computer
|
|
|
|
|
Try to read this article.[^]
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
how can i create a relationship beween scaner and a form in vb
|
|
|
|
|
Hi, in vb6 in the code windows if i want to delete a single line of code at a time, I could press the shortcut key Ctrl + Y
But in vb.net this method is not working. Does anyone know how to delete a single line of code at a time by using shortcut key in vb.net?
A thousand mile of journey, begin with the first step.
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
i have a medical application. once the doctor selects a patient for consultation. there are a list of differnt diagnosis which can be selected multiple for a single patient at a time.Now each diagnosis has differnt findings and surgerys booked for the diagnosis.These findings are 40% common in all diagnosis and rest are differnt. Now there are around 20 diagnosis. my clinet wants to see the selected diagnosis findingson a findings form and surgery information for all selected in surgery form. i cannot make all the controls for differnt findingds on the same form a make visisble true false according to the selected. and making controls at runtime will be cumbersome.can any body tell me the flow to do this. any further information needed will be provided.
Thanks
Monica
|
|
|
|
|
monica2k wrote:
i cannot make all the controls for differnt findingds on the same form a make visisble true false according to the selected.
I am not sure what this means.
monica2k wrote:
making controls at runtime will be cumbersome
Why ?
monica2k wrote:
can any body tell me the flow to do this
You have two options - one is fill the form with all options and hide some. This is ugly. Two is create the controls dynamically. That is what you should do, that way you control how many controls you have, as well as what's on tehm
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I've developed a home winform application and I want execute it from another computer connected. But it make an security exception "This application is running in a partially trusted context..."
Anyone can help me to solve this problem. I dont need any security. I just want to remove this validation in order to test my application.
Thank you.
Regards
German
german
|
|
|
|
|
If you were to have a VB project with several forms included. Is there a way to programmatically check which form is the active one without checking each form individually. I am implementing some error checking code and I trying to programmatically trace back in my code to the point of the user button click. In order to generate a useful error message. Does anyone have any ideas?
|
|
|
|
|
If your form has try ... catch statements then in the catch you can log the exception data which contains the stack of all methods called including the line number where error ocurred.
Look into Exception.Stacktrace to get the list of methods called, and also look at Exception.TargetSite.DeclaringType to get the method name where error ocurred.
|
|
|
|
|
I have a windows form that contains a tab control that contains a single tab page. The autoscroll property is set to True. I'm adding controls, labels in this case. If I set the top property before I add it to the tab page everything works fine. But if I set the top property after adding the label to the tab page and I'm trying to set it to anyting larger than 32676, it simply sets it to 32676 but with no errors. The following is the code I used.
Dim _worksurface As System.Windows.Forms.TabControl
_Worksurface = New System.Windows.Forms.TabControl
_Worksurface.Dock = DockStyle.Fill
_Worksurface.Appearance = TabAppearance.Normal
Dim tp As New System.Windows.Forms.TabPage
tp.AutoScroll = True
tp.Text = "Tab Page"
_Worksurface.TabPages.Add(tp)
Me.Controls.Add(_Worksurface)
Dim l As System.Windows.Forms.Label
Dim OffSet As Integer = 0
For i As Integer = 1 To 10
l = New System.Windows.Forms.Label
l.Text = "Steve-" & i
'l.Top = 32700 + OffSet
tp.Controls.Add(l)
l.Top = 32700 + OffSet
OffSet += 1000
Next
'TRY TO REPOSITION THE LABELS
For Each lab As System.Windows.Forms.Label In tp.Controls
lab.Top = lab.Top + 1
Next
|
|
|
|
|
Your mistake is while using the loop to change the position,
For..Each is ---> READ ONLY LOOP
use For..Next instead
bye
|
|
|
|