How to change the Design view - vb.net

I'm new to the programming, just got limited knowledge. I got a doubt, seems silly for u professionals. I have a program for Pay slip generator. It doesn't show the design on designer view. It just a empty window. Will get the payslip on runtime. Can you please help me...
Partial Class frmSalarySlip
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
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.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmSalarySlip))
Me.CrystalReportViewer1 = New CrystalDecisions.Windows.Forms.CrystalReportViewer()
Me.SuspendLayout()
'
'CrystalReportViewer1
'
Me.CrystalReportViewer1.ActiveViewIndex = -1
Me.CrystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.CrystalReportViewer1.Cursor = System.Windows.Forms.Cursors.Default
Me.CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill
Me.CrystalReportViewer1.Location = New System.Drawing.Point(0, 0)
Me.CrystalReportViewer1.Name = "CrystalReportViewer1"
Me.CrystalReportViewer1.Size = New System.Drawing.Size(1007, 498)
Me.CrystalReportViewer1.TabIndex = 0
'
'frmSalarySlip
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(1007, 498)
Me.Controls.Add(Me.CrystalReportViewer1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.Name = "frmSalarySlip"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Monthly Salary Slip"
Me.ResumeLayout(False)
End Sub

Related

Cannot open designer of a form

I am currently working on a project using MS VS 2017.
I was able to open the designer and open the forms before. Now, I'm trying to open the same file but all forms' designers cannot be opened. But the project runs smoothly and I can edit the code.
I tried what others have suggested, like cleaning and building the solution, and deleting the obj subfolder, however none of these worked for me. What should I do?
This is what I get every time I try to open the designer:
The designer could not be shown for this file because none of the classes within it can be designed.
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at
Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)
This is the code of the form I am trying to open:
Public Class frmLogin
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
Application.Exit()
End Sub
Private Sub lblExit_Click_1(sender As Object, e As EventArgs) Handles lblExit.Click
If (MessageBox.Show("Are you sure to Exit?", "Exit from the system", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) = DialogResult.Yes Then
Application.Exit()
End If
End Sub
Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
frmDashboard.Show()
Me.Hide()
End Sub
End Class
The file you need to look at is frmLogin.Designer.vb in your project directory. You can see it by right-clicking (in Visual Studio), for instance "btnLogin" in the code that you posted above, then "Go To Implementation". Or just use File Explorer and open the file with NotePad to see inside.
This is where the design for your form is stored. The file contains auto-generated code and data for your form, and seems to be corrupted somehow, maybe it was accidentally edited.
I have no idea what frmLogin actually looks like, but here is a frmLogin.Designer.vb I just created using the names in your code;
I suggest you compare the contents of your file with the example below which should lead to the source of your problem:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class frmLogin
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()>
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
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.
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Me.btnCancel = New System.Windows.Forms.Button()
Me.btnLogin = New System.Windows.Forms.Button()
Me.lblExit = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'btnCancel
'
Me.btnCancel.Location = New System.Drawing.Point(310, 130)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.Size = New System.Drawing.Size(107, 43)
Me.btnCancel.TabIndex = 0
Me.btnCancel.Text = "Cancel"
Me.btnCancel.UseVisualStyleBackColor = True
'
'btnLogin
'
Me.btnLogin.Location = New System.Drawing.Point(310, 192)
Me.btnLogin.Name = "btnLogin"
Me.btnLogin.Size = New System.Drawing.Size(107, 48)
Me.btnLogin.TabIndex = 1
Me.btnLogin.Text = "Log in"
Me.btnLogin.UseVisualStyleBackColor = True
'
'lblExit
'
Me.lblExit.AutoSize = True
Me.lblExit.Location = New System.Drawing.Point(233, 130)
Me.lblExit.Name = "lblExit"
Me.lblExit.Size = New System.Drawing.Size(24, 13)
Me.lblExit.TabIndex = 2
Me.lblExit.Text = "Exit"
'
'frmLogin
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(800, 450)
Me.Controls.Add(Me.lblExit)
Me.Controls.Add(Me.btnLogin)
Me.Controls.Add(Me.btnCancel)
Me.Name = "frmLogin"
Me.Text = "frmLogin"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents btnCancel As Button
Friend WithEvents btnLogin As Button
Friend WithEvents lblExit As Label
End Class
Good luck!
I had the same issue where the project would build and run but the Windows Forms designer refused to display any forms or controls.
I had to delete the ProjectAssemblies directory and reopen the project and then it worked fine.
%LOCALAPPDATA%\Microsoft\VisualStudio*16.0_72ecbfa4*\ProjectAssemblies

Windows Form not loading

I created a windows form design and here is the auto-generated code
{...}
'
'PosEmea17_2
'
Me.AcceptButton = Me.rapportGenerieren
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.AutoSize = True
Me.BackColor = System.Drawing.SystemColors.Control
Me.ClientSize = New System.Drawing.Size(448, 219)
Me.Controls.Add(Me.rapportGenerieren)
Me.Controls.Add(Me.bis2)
Me.Controls.Add(Me.bis1)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.von2)
Me.Controls.Add(Me.von1)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label1)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "PosEmea17_2"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Pos EMEA"
Me.TopMost = True
Me.ResumeLayout(False)
Me.PerformLayout()
{...}
Here the call of the form
Public Sub CreateFormWith2DateRange()
Dim oFormPosEmea As PosEmea17_2 = New PosEmea17_2
oFormPosEmea.Show()
End Sub
When I'm calling this form he's hanging in the middle of the screen like he wasn't loaded.
EDIT
After putting a new constructor the form is displayed but the labels are not loaded.
Public Sub New()
InitializeComponent()
End Sub
EDIT 2
Wenn using ShowDialog() the form is displayed and works but wenn I move it the update of the screen is laggy
Finally my problem was related to the fact I was creating my form in the middle of "SAP". Should have used SAP built in functions.

.NET (4.5) ListView - add/remove column bug(?)

I came across an awkward (that is, unexpected for me) behaviour of the .NET Listview. The issue may have been posted before. If so, apologies for the duplication: I didn't find it and would appreciate being pointed to "the" discussion.
Context: I'm using VisualStudio 2013, VB, target framework 4.5
Build a Form with a listview and a few buttons.
The ListView (Details-view) is initially configured with 1 column labeled "1" and 2 rows, each containing a "1".
Then there's a button to Add a column with header "A" (if it's not there yet) and for each listviewItem a subitem "a". Likewise for a column "B" with subitem "b".
Finally there are buttons to remove columns "A" and "B" respectively.
Now, if I do the following:
Add "A"
Delete "A"
Add "B"
I wind up with a column "B" (header) with column contents "a", i.e. those of the "removed" column "A".
Playing around you always find that upon removal of a column (listview.columns.removeBykey('key'), for instance) the subitems seem to persist "invisibly" and come to life if "any" columnHeader is added later on.
I'm not looking for help to solve a programming problem: there's an easy way around (whenever you remove a column, also remove explicitly the corresponding subitems from each listviewItem), but it puzzles me that this clumsy (in my view) approach would be necessary.
Maybe I don't properly use/configure the listview and should have known all this. Any comment is appreciated.
I copy the code below, to make it easier to verify for anyone interested.
(Designer code)
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
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.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.lvStd = New System.Windows.Forms.ListView()
Me.btnAdd_A = New System.Windows.Forms.Button()
Me.btnDel_A = New System.Windows.Forms.Button()
Me.btnAdd_B = New System.Windows.Forms.Button()
Me.btnDel_B = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'lvStd
'
Me.lvStd.Dock = System.Windows.Forms.DockStyle.Top
Me.lvStd.Location = New System.Drawing.Point(0, 0)
Me.lvStd.Name = "lvStd"
Me.lvStd.Size = New System.Drawing.Size(661, 207)
Me.lvStd.TabIndex = 0
Me.lvStd.UseCompatibleStateImageBehavior = False
Me.lvStd.View = System.Windows.Forms.View.Details
'
'btnAdd_A
'
Me.btnAdd_A.Location = New System.Drawing.Point(12, 235)
Me.btnAdd_A.Name = "btnAdd_A"
Me.btnAdd_A.Size = New System.Drawing.Size(75, 23)
Me.btnAdd_A.TabIndex = 1
Me.btnAdd_A.Text = "Add A"
Me.btnAdd_A.UseVisualStyleBackColor = True
'
'btnDel_A
'
Me.btnDel_A.Location = New System.Drawing.Point(12, 264)
Me.btnDel_A.Name = "btnDel_A"
Me.btnDel_A.Size = New System.Drawing.Size(75, 23)
Me.btnDel_A.TabIndex = 2
Me.btnDel_A.Text = "Del A"
Me.btnDel_A.UseVisualStyleBackColor = True
'
'btnAdd_B
'
Me.btnAdd_B.Location = New System.Drawing.Point(159, 235)
Me.btnAdd_B.Name = "btnAdd_B"
Me.btnAdd_B.Size = New System.Drawing.Size(75, 23)
Me.btnAdd_B.TabIndex = 3
Me.btnAdd_B.Text = "Add B"
Me.btnAdd_B.UseVisualStyleBackColor = True
'
'btnDel_B
'
Me.btnDel_B.Location = New System.Drawing.Point(159, 264)
Me.btnDel_B.Name = "btnDel_B"
Me.btnDel_B.Size = New System.Drawing.Size(75, 23)
Me.btnDel_B.TabIndex = 4
Me.btnDel_B.Text = "Del B"
Me.btnDel_B.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(661, 474)
Me.Controls.Add(Me.btnDel_B)
Me.Controls.Add(Me.btnAdd_B)
Me.Controls.Add(Me.btnDel_A)
Me.Controls.Add(Me.btnAdd_A)
Me.Controls.Add(Me.lvStd)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
Friend WithEvents lvStd As System.Windows.Forms.ListView
Friend WithEvents btnAdd_A As System.Windows.Forms.Button
Friend WithEvents btnDel_A As System.Windows.Forms.Button
Friend WithEvents btnAdd_B As System.Windows.Forms.Button
Friend WithEvents btnDel_B As System.Windows.Forms.Button
End Class
and the "Form" code:
Public Class Form1
Protected Overrides Sub OnLoad(e As EventArgs)
MyBase.OnLoad(e)
If (Me.DesignMode) Then Return
Me.Configure()
Me.FillList()
End Sub
Private Sub Configure()
Me.lvStd.BeginUpdate()
Me.lvStd.Clear()
Me.lvStd.Columns.Add("1")
Me.lvStd.EndUpdate()
End Sub
Private Sub FillList()
Dim LI As ListViewItem
For k As Integer = 1 To 2
LI = Me.lvStd.Items.Add("1")
Next
End Sub
Private Sub btnAdd_A_Click(sender As Object, e As EventArgs) Handles btnAdd_A.Click
Dim col As ColumnHeader = Me.lvStd.Columns("A")
If (col IsNot Nothing) Then
Return
End If
Me.lvStd.Columns.Add("A", "A")
For Each LI As ListViewItem In Me.lvStd.Items
LI.SubItems.Add("a")
Next
End Sub
Private Sub btnDel_A_Click(sender As Object, e As EventArgs) Handles btnDel_A.Click
Dim col As ColumnHeader = Me.lvStd.Columns("A")
If (col IsNot Nothing) Then
Me.lvStd.Columns.Remove(col)
End If
End Sub
Private Sub btnAdd_B_Click(sender As Object, e As EventArgs) Handles btnAdd_B.Click
Dim col As ColumnHeader = Me.lvStd.Columns("B")
If (col IsNot Nothing) Then
Return
End If
Me.lvStd.Columns.Add("B", "B")
For Each LI As ListViewItem In Me.lvStd.Items
LI.SubItems.Add("b")
Next
End Sub
Private Sub btnDel_B_Click(sender As Object, e As EventArgs) Handles btnDel_B.Click
Dim col As ColumnHeader = Me.lvStd.Columns("B")
If (col IsNot Nothing) Then
Me.lvStd.Columns.Remove(col)
End If
End Sub
End Class

cannot copy paste from datagridview

I have a simple blank windows form as a test project
and a datagridview
and a query to fill the datagridview
in this test project. I can highlight all the columns and rows
click CTRL + C
open excel
then click ctrl + V
and the data is there.
but on a program that I inherited from someone in the company
I have a similar data grid view. but I cannot copy paste
how can I identify what is the difference here?
I check the data grid view properties for both test project and the program I inherited. both has the same following:
1. the read only = false
2. the copyclipboardmode = EnableWithAutoHeaderText
what else could prevent me from copy paste this value?
in the inherited program the only way to copy paste ist by double click the cell and copy, but. this limits me to copy one cell at a time , instead of multiple cell
please advise?
thank you
this is the code snippet from my test project
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
DataGridView1.Rows.Add(New String() {"TEST", "TEST2", "TEST3"})
DataGridView1.Rows.Add(New String() {"TEST", "TEST2", "TEST3"})
DataGridView1.Rows.Add(New String() {"TEST", "TEST2", "TEST3"})
DataGridView1.Rows.Add(New String() {"TEST", "TEST2", "TEST3"})
DataGridView1.Rows.Add(New String() {"TEST", "TEST2", "TEST3"})
DataGridView1.Rows.Add(New String() {"TEST", "TEST2", "TEST3"})
DataGridView1.Rows.Add(New String() {"TEST", "TEST2", "TEST3"})
End Sub
This is the frmForm.Designer.vb as requested by QuickDanger
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmForm
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
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.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.dgvSpecials = New System.Windows.Forms.DataGridView()
Me.btnCreate = New System.Windows.Forms.Button()
Me.PartCode = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.PDF = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.SLDDRW = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.SLDPRT = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.BasePartCode = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.TEMPLATESLDDRW = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.TEMPLATESLDPRT = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.TEMPLATEDRWFILE = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.TEMPLATEPRTFILE = New System.Windows.Forms.DataGridViewTextBoxColumn()
Me.MakeSpecial = New System.Windows.Forms.DataGridViewCheckBoxColumn()
CType(Me.dgvSpecials, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'dgvSpecials
'
Me.dgvSpecials.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
Me.dgvSpecials.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.PartCode, Me.PDF, Me.SLDDRW, Me.SLDPRT, Me.BasePartCode, Me.TEMPLATESLDDRW, Me.TEMPLATESLDPRT, Me.TEMPLATEDRWFILE, Me.TEMPLATEPRTFILE, Me.MakeSpecial})
Me.dgvSpecials.Dock = System.Windows.Forms.DockStyle.Fill
Me.dgvSpecials.Location = New System.Drawing.Point(0, 0)
Me.dgvSpecials.Name = "dgvSpecials"
Me.dgvSpecials.Size = New System.Drawing.Size(917, 246)
Me.dgvSpecials.TabIndex = 0
'
'btnCreate
'
Me.btnCreate.Dock = System.Windows.Forms.DockStyle.Bottom
Me.btnCreate.Location = New System.Drawing.Point(0, 246)
Me.btnCreate.Name = "btnCreate"
Me.btnCreate.Size = New System.Drawing.Size(917, 30)
Me.btnCreate.TabIndex = 1
Me.btnCreate.Text = "Create"
Me.btnCreate.UseVisualStyleBackColor = True
'
'PartCode
'
Me.PartCode.HeaderText = "Part Code"
Me.PartCode.Name = "PartCode"
Me.PartCode.ReadOnly = True
Me.PartCode.Width = 200
'
'PDF
'
Me.PDF.HeaderText = "PDF"
Me.PDF.Name = "PDF"
Me.PDF.ReadOnly = True
'
'SLDDRW
'
Me.SLDDRW.HeaderText = "SLDDRW"
Me.SLDDRW.Name = "SLDDRW"
Me.SLDDRW.ReadOnly = True
'
'SLDPRT
'
Me.SLDPRT.HeaderText = "SLDPRT"
Me.SLDPRT.Name = "SLDPRT"
Me.SLDPRT.ReadOnly = True
'
'BasePartCode
'
Me.BasePartCode.HeaderText = "Base Part"
Me.BasePartCode.Name = "BasePartCode"
Me.BasePartCode.ReadOnly = True
'
'TEMPLATESLDDRW
'
Me.TEMPLATESLDDRW.HeaderText = "DRW Template"
Me.TEMPLATESLDDRW.Name = "TEMPLATESLDDRW"
Me.TEMPLATESLDDRW.ReadOnly = True
'
'TEMPLATESLDPRT
'
Me.TEMPLATESLDPRT.HeaderText = "PRT Template"
Me.TEMPLATESLDPRT.Name = "TEMPLATESLDPRT"
'
'TEMPLATEDRWFILE
'
Me.TEMPLATEDRWFILE.HeaderText = "Column1"
Me.TEMPLATEDRWFILE.Name = "TEMPLATEDRWFILE"
Me.TEMPLATEDRWFILE.ReadOnly = True
Me.TEMPLATEDRWFILE.Visible = False
'
'TEMPLATEPRTFILE
'
Me.TEMPLATEPRTFILE.HeaderText = "Column1"
Me.TEMPLATEPRTFILE.Name = "TEMPLATEPRTFILE"
Me.TEMPLATEPRTFILE.ReadOnly = True
Me.TEMPLATEPRTFILE.Visible = False
'
'MakeSpecial
'
Me.MakeSpecial.HeaderText = "MakeSpecial"
Me.MakeSpecial.Name = "MakeSpecial"
'
'frmForm
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(917, 276)
Me.Controls.Add(Me.dgvSpecials)
Me.Controls.Add(Me.btnCreate)
Me.Name = "frmForm"
Me.Text = "frmForm"
CType(Me.dgvSpecials, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
Friend WithEvents dgvSpecials As System.Windows.Forms.DataGridView
Friend WithEvents btnCreate As System.Windows.Forms.Button
Friend WithEvents PartCode As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents PDF As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents SLDDRW As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents SLDPRT As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents BasePartCode As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents TEMPLATESLDDRW As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents TEMPLATESLDPRT As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents TEMPLATEDRWFILE As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents TEMPLATEPRTFILE As System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents MakeSpecial As System.Windows.Forms.DataGridViewCheckBoxColumn
End Class
Here is the actual frmForm.VB
SldWorks is member of SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.sldworks
Public Class frmForm
Dim App As SldWorks
Public Sub Setup(App As SldWorks, Arr As ArrayList)
End Sub
Private Sub btnCreate_Click(sender As Object, e As EventArgs) Handles btnCreate.Click
End Sub
End Class
I am guessing that you have to set MultiSelect property of the DataGridView to true
I guess you have set ClipboardCopyMode to Disable. Change this property to any other three available options.
Other developer use Ctrl+C for some shortcut key in his project.
If you can check his design,Please go through property of Menubar->ShortcutKeys
It looks like others have had success with ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText
(see this SO question). If that doesn't help, could you paste the designer code for the dataGridView? (it is found in the project file [formname].Designer.vb)
You might also want to search the code for references to this control, and verify that the original developer did not modify the ClipboardCopyMode property at run-time.
Edit: Since none of the suggestions seem to be working, you could "roll your own" version of copy/paste using a tab-delimited format:
Note: This copies all data, not just selected cells, but you can modify it to only do selected cells.
Private Sub DataGridView1_KeyUp(sender As Object, e As KeyEventArgs) Handles DataGridView1.KeyUp
If e.KeyCode = Keys.C AndAlso e.Control Then
Dim sb = New StringBuilder()
' If you want the headers, keep these two lines
Dim headers = DataGridView1.Columns.Cast(Of DataGridViewColumn)()
sb.AppendLine(String.Join(vbTab, headers.[Select](Function(column) Convert.ToString(column.HeaderText)).ToArray()))
For Each row As DataGridViewRow In DataGridView1.Rows
Dim cells = row.Cells.Cast(Of DataGridViewCell)()
sb.AppendLine(String.Join(vbTab, cells.[Select](Function(cell) Convert.ToString(cell.Value)).ToArray()))
Next
My.Computer.Clipboard.SetText(sb.ToString)
End If
End Sub
Solved: this problem is due to solidWorks.Interop.sldworks and the application being in Solidworks environment
I've heard from other solidworks developers the ctrl C just refused to work
For copying data from the datagridview, we are getting multiple errors. So, I have developed following code for my application for this purpose using the help of QuickDanger from the above .
Private Sub grdDetails_KeyUp(sender As Object, e As KeyEventArgs) Handles grdDetails.KeyUp
Try
If e.KeyCode = Keys.C AndAlso e.Control Then
Dim mGrid As DataGridView, mCol As DataGridViewColumn, mRow As DataGridViewRow, mCell As DataGridViewCell
Dim mStrBld As New StringBuilder
mGrid = CType(sender, DataGridView)
' Copying Header
For Each mCol In mGrid.Columns
If mCol.HeaderText IsNot Nothing Then
mStrBld.Append(vbTab & mCol.HeaderText)
Else
mStrBld.Append(vbTab & "")
End If
Next
mStrBld.Append(vbCrLf)
' Copying Data
If mGrid.Rows.Count > 0 Then
'Display progress in Progress Bar if rows are more
'ProgressBar1.Minimum = 0 : ProgressBar1.Value = 0 : ProgressBar1.Maximum = mGrid.Rows.Count : ProgressBar1.Step = 1 : ProgressBar1.Visible = True
For Each mRow In mGrid.Rows
For Each mCell In mRow.Cells
If mCell IsNot Nothing AndAlso mCell.Value IsNot Nothing Then
mStrBld.Append(vbTab & mCell.Value.ToString)
Else
mStrBld.Append(vbTab & "")
End If
Next
mStrBld.Append(vbCrLf)
'ProgressBar1.PerformStep()
Next
' sending data to clipboard, so we can safely past the same
My.Computer.Clipboard.SetText(mStrBld.ToString)
'ProgressBar1.Visible = False
Else
MsgBox("No Data...1", MsgBoxStyle.Critical)
End If
End If
e.Handled = True
Catch ex As Exception
MsgBox("Error:" & ex.Message)
End Try
End Sub

Position of controls on different computers

I have a form with a tab control. Above it, there are lables, combo boxes and text boxes.
On the development machine, it works fine but on other machines, where resolution is different, the position of the controls is changed. Somewhere combo box overlaps the tab control, somewhere text boxes and lables are not aligned with each other.
How to set it so that my application maintains the shape no matter what resolution it is.
I tried AutoScaleMode to dpi, inherit etc. but nothing worked.
Thanks
I always use layout panels, particularly the TableLayoutPanel. For any row that contains a ComboBox or TextBox, I set the row's height to AutoSize. Similarly, a Label goes in an AutoSize column. Your TabPanel can span across several columns. In columns with set sizes (Absolute or Percent), set the child control's Anchor to Left & Right to fill the entire column.
Not only does the screen resolution change things, but the DPI. DPI is a Windows setting that enlarges all controls, useful on monitors with fine pixels rather than chunky pixels. With AutoSize, the controls can automatically enlarge, then
Copy and paste this code into Form1.Designer.vb for an example. Take note of the Anchor property of each control, and the size settings for each row and column.
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
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.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel()
Me.Label1 = New System.Windows.Forms.Label()
Me.ComboBox1 = New System.Windows.Forms.ComboBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.TabControl1 = New System.Windows.Forms.TabControl()
Me.TabPage1 = New System.Windows.Forms.TabPage()
Me.TabPage2 = New System.Windows.Forms.TabPage()
Me.TableLayoutPanel1.SuspendLayout()
Me.TabControl1.SuspendLayout()
Me.SuspendLayout()
'
'TableLayoutPanel1
'
Me.TableLayoutPanel1.ColumnCount = 4
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle())
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle())
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
Me.TableLayoutPanel1.Controls.Add(Me.Label1, 0, 0)
Me.TableLayoutPanel1.Controls.Add(Me.ComboBox1, 1, 0)
Me.TableLayoutPanel1.Controls.Add(Me.Label2, 2, 0)
Me.TableLayoutPanel1.Controls.Add(Me.TextBox1, 3, 0)
Me.TableLayoutPanel1.Controls.Add(Me.TabControl1, 0, 1)
Me.TableLayoutPanel1.Location = New System.Drawing.Point(12, 12)
Me.TableLayoutPanel1.Name = "TableLayoutPanel1"
Me.TableLayoutPanel1.RowCount = 2
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle())
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100.0!))
Me.TableLayoutPanel1.Size = New System.Drawing.Size(260, 238)
Me.TableLayoutPanel1.TabIndex = 0
'
'Label1
'
Me.Label1.Anchor = System.Windows.Forms.AnchorStyles.Right
Me.Label1.AutoSize = True
Me.Label1.Name = "Label1"
Me.Label1.TabIndex = 0
Me.Label1.Text = "Label1"
'
'ComboBox1
'
Me.ComboBox1.Anchor = CType((System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.ComboBox1.FormattingEnabled = True
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.TabIndex = 1
'
'Label2
'
Me.Label2.Anchor = System.Windows.Forms.AnchorStyles.Right
Me.Label2.AutoSize = True
Me.Label2.Name = "Label2"
Me.Label2.TabIndex = 2
Me.Label2.Text = "Label2"
'
'TextBox1
'
Me.TextBox1.Anchor = CType((System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 3
'
'TabControl1
'
Me.TabControl1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.TableLayoutPanel1.SetColumnSpan(Me.TabControl1, 4)
Me.TabControl1.Controls.Add(Me.TabPage1)
Me.TabControl1.Controls.Add(Me.TabPage2)
Me.TabControl1.Name = "TabControl1"
Me.TabControl1.TabIndex = 4
'
'TabPage1
'
Me.TabPage1.Name = "TabPage1"
Me.TabPage1.Padding = New System.Windows.Forms.Padding(3)
Me.TabPage1.TabIndex = 0
Me.TabPage1.Text = "TabPage1"
Me.TabPage1.UseVisualStyleBackColor = True
'
'TabPage2
'
Me.TabPage2.Name = "TabPage2"
Me.TabPage2.Padding = New System.Windows.Forms.Padding(3)
Me.TabPage2.TabIndex = 1
Me.TabPage2.Text = "TabPage2"
Me.TabPage2.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(284, 262)
Me.Controls.Add(Me.TableLayoutPanel1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.TableLayoutPanel1.ResumeLayout(False)
Me.TableLayoutPanel1.PerformLayout()
Me.TabControl1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
Friend WithEvents TabPage2 As System.Windows.Forms.TabPage
End Class