|
-
Aug 19th, 2012, 09:02 AM
#1
Thread Starter
Lively Member
Datagrid select error
Code:
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Public Class hesap
#Region " text alan "
Protected Overrides Sub OnResize(ByVal e As EventArgs)
MyBase.OnResize(e)
Me.Button1.Left = (Me.MaskedTextBox1.Width - Me.Button1.Width)
End Sub
#End Region
#Region " Plan Tanıtım "
Protected Class hesapplani
Inherits System.Windows.Forms.Form
Private Mydgv As hesap
Private WithEvents dgv As System.Windows.Forms.DataGridView
Public Sub New(ByRef plan As hesap)
Mydgv = plan
Me.dgv = New System.Windows.Forms.DataGridView
Me.SuspendLayout()
Me.dgv.Location = New System.Drawing.Point(0, 0)
Me.dgv.Margin = New System.Windows.Forms.Padding(0)
Me.dgv.Name = "datagrid"
Me.dgv.TabIndex = 0
Me.dgv.Dock = DockStyle.Fill
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(295, 614)
Me.ControlBox = True
Me.Controls.Add(Me.dgv)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable
Me.MaximizeBox = True
Me.MinimizeBox = True
Me.Name = "Hesap Planı"
'Me.ShowIcon = False
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.ResumeLayout(False)
End Sub
Private Sub hesapplani_Load(sender As Object, e As EventArgs) Handles Me.Load
If baglanti.State = ConnectionState.Closed Then baglanti.Open()
dategetir(dgv, "select kodu,adi from hesapplani")
baglanti.Close()
End Sub
End Class
#End Region
Private Sub MaskedTextBox1_GotFocus(sender As Object, e As EventArgs) Handles MaskedTextBox1.GotFocus
MaskedTextBox1.Select(0, 1)
End Sub
Private Sub MaskedTextBox1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles MaskedTextBox1.Resize
' SetButton()
Me.Height = MaskedTextBox1.Height
End Sub
Private Sub MaskedTextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles MaskedTextBox1.TextChanged
'RaiseEvent TextChanged(Me, EventArgs.Empty)
End Sub
Private hesaplar As hesapplani
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If hesaplar Is Nothing Then hesaplar = New hesapplani(Me)
hesaplar.ShowDialog()
End Sub
Private Sub dgv_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs)
Me.MaskedTextBox1.Text = Me.dgv.Rows(Me.dgv.CurrentRow.Index).Cells(0).Value
End Sub
End Class
ERROR
Code:
Private Sub dgv_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs)
Me.MaskedTextBox1.Text = Me.dgv.Rows(Me.dgv.CurrentRow.Index).Cells(0).Value
End Sub
I can not select data from datagrid
-
Aug 19th, 2012, 10:04 AM
#2
Re: Datagrid select error
Me.MaskedTextBox1.Text = Me.dgv.Rows(Me.dgv.CurrentRow.Index).Cells(0).Value.ToString
-
Aug 19th, 2012, 10:10 AM
#3
Thread Starter
Lively Member
Re: Datagrid select error
has failed again
-
Aug 19th, 2012, 10:18 AM
#4
Thread Starter
Lively Member
Re: Datagrid select error
Public function()
I need to create a selection. the other is a separate table for another table. choice is going to be a function of
-
Aug 19th, 2012, 10:26 AM
#5
Re: Datagrid select error
Do you have more than one form? Is dgv actually on the form you're coding for?
-
Aug 19th, 2012, 10:31 AM
#6
Thread Starter
Lively Member
Re: Datagrid select error
Code:
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Public Class hesap
#Region " text alan "
Protected Overrides Sub OnResize(ByVal e As EventArgs)
MyBase.OnResize(e)
Me.Button1.Left = (Me.MaskedTextBox1.Width - Me.Button1.Width)
End Sub
#End Region
#Region " Plan Tanıtım "
Protected Class hesapplani
Inherits System.Windows.Forms.Form
Private Mydgv As hesap
Private WithEvents dgv As System.Windows.Forms.DataGridView
Public Sub New(ByRef plan As hesap)
Mydgv = plan
Me.dgv = New System.Windows.Forms.DataGridView
Me.SuspendLayout()
Me.dgv.Location = New System.Drawing.Point(0, 0)
Me.dgv.Margin = New System.Windows.Forms.Padding(0)
Me.dgv.Name = "datagrid"
Me.dgv.TabIndex = 0
Me.dgv.Dock = DockStyle.Fill
Me.dgv.AllowUserToAddRows = False
Me.dgv.ReadOnly = True
Me.dgv.AllowUserToDeleteRows = False
Me.dgv.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing
Me.dgv.AllowUserToResizeColumns = False
Me.dgv.AllowUserToResizeRows = False
Me.dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
Me.dgv.RowHeadersWidth = 15
Me.dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(450, 614)
Me.ControlBox = True
Me.Controls.Add(Me.dgv)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable
Me.MaximizeBox = True
Me.MinimizeBox = True
Me.Name = "HesapPlanı"
'Me.ShowIcon = False
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.ResumeLayout(False)
End Sub
Private Sub hesapplani_Load(sender As Object, e As EventArgs) Handles Me.Load
If baglanti.State = ConnectionState.Closed Then baglanti.Open()
dategetir(dgv, "select kodu,adi from hesapplani")
baglanti.Close()
End Sub
Public Sub secelim()
Dim secelim As Integer = dgv.Rows(dgv.CurrentRow.Index).Cells(0).Value.ToString()
End Sub
End Class
#End Region
Private Sub MaskedTextBox1_GotFocus(sender As Object, e As EventArgs) Handles MaskedTextBox1.GotFocus
MaskedTextBox1.Select(0, 1)
End Sub
Private Sub MaskedTextBox1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles MaskedTextBox1.Resize
Me.Height = MaskedTextBox1.Height
End Sub
Private hesaplar As hesapplani
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If hesaplar Is Nothing Then hesaplar = New hesapplani(Me)
hesaplar.ShowDialog()
End Sub
Private Sub dgv_CellClick(sender As Object, e As DataGridViewCellEventArgs)
Me.MaskedTextBox1.Text = hesaplar.secelim
End Sub
End Class
-
Aug 19th, 2012, 10:34 AM
#7
Thread Starter
Lively Member
Re: Datagrid select error
I have a usercontrol datagrid to create a form from there I added codes. paintings, so that is the name of an account at one hesapplani
-
Aug 19th, 2012, 10:43 AM
#8
Re: Datagrid select error
vb.net Code:
Public Sub secelim()
Dim secelim As Integer = dgv.Rows(dgv.CurrentRow.Index).Cells(0).Value 'so now NOT .ToString()
End Sub
vb.net Code:
Private Sub dgv_CellClick(sender As Object, e As DataGridViewCellEventArgs)
Me.MaskedTextBox1.Text = hesaplar.secelim.ToString '.Text is always String, Integer is NOT String
End Sub
-
Aug 19th, 2012, 10:50 AM
#9
Thread Starter
Lively Member
Re: Datagrid select error
I'm sorry it did not. bridge the gap between problem-created account and the account plan
Code:
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Public Class hesap
#Region " text alan "
Protected Overrides Sub OnResize(ByVal e As EventArgs)
MyBase.OnResize(e)
Me.Button1.Left = (Me.MaskedTextBox1.Width - Me.Button1.Width)
End Sub
#End Region
#Region " Plan Tanıtım "
Protected Class hesapplani
Inherits System.Windows.Forms.Form
Private Mydgv As hesap
Private WithEvents dgv As System.Windows.Forms.DataGridView
Public Sub New(ByRef plan As hesap)
Mydgv = plan
Me.dgv = New System.Windows.Forms.DataGridView
Me.SuspendLayout()
Me.dgv.Location = New System.Drawing.Point(0, 0)
Me.dgv.Margin = New System.Windows.Forms.Padding(0)
Me.dgv.Name = "datagrid"
Me.dgv.TabIndex = 0
Me.dgv.Dock = DockStyle.Fill
Me.dgv.AllowUserToAddRows = False
Me.dgv.ReadOnly = True
Me.dgv.AllowUserToDeleteRows = False
Me.dgv.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing
Me.dgv.AllowUserToResizeColumns = False
Me.dgv.AllowUserToResizeRows = False
Me.dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
Me.dgv.RowHeadersWidth = 15
Me.dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(450, 614)
Me.ControlBox = True
Me.Controls.Add(Me.dgv)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable
Me.MaximizeBox = True
Me.MinimizeBox = True
Me.Name = "HesapPlanı"
Me.Text = "Hesap Planı"
'Me.ShowIcon = False
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.ResumeLayout(False)
End Sub
Private Sub hesapplani_Load(sender As Object, e As EventArgs) Handles Me.Load
If baglanti.State = ConnectionState.Closed Then baglanti.Open()
dategetir(dgv, "select kodu,adi from hesapplani")
baglanti.Close()
End Sub
Private Sub dgv_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgv.Click
hesap.MaskedTextBox1.Text = Me.dgv.Rows(Me.dgv.CurrentRow.Index).Cells(0).Value.ToString()
End Sub
End Class
#End Region
Private Sub MaskedTextBox1_GotFocus(sender As Object, e As EventArgs) Handles MaskedTextBox1.GotFocus
MaskedTextBox1.Select(0, 1)
End Sub
Private Sub MaskedTextBox1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles MaskedTextBox1.Resize
Me.Height = MaskedTextBox1.Height
End Sub
Private hesaplar As hesapplani
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If hesaplar Is Nothing Then hesaplar = New hesapplani(Me)
hesaplar.ShowDialog()
End Sub
End Class
-
Aug 19th, 2012, 10:52 AM
#10
Thread Starter
Lively Member
Re: Datagrid select error
 Originally Posted by dunfiddlin
hesap is in the field of
vb.net Code:
Public Sub secelim() Dim secelim As Integer = dgv.Rows(dgv.CurrentRow.Index).Cells(0).Value 'so now NOT .ToString() End Sub
plan is in the field of
vb.net Code:
Private Sub dgv_CellClick(sender As Object, e As DataGridViewCellEventArgs) Me.MaskedTextBox1.Text = hesaplar.secelim.ToString '.Text is always String, Integer is NOT String End Sub
need to be the exact opposite.
-
Aug 19th, 2012, 10:54 AM
#11
Thread Starter
Lively Member
Re: Datagrid select error
2012 to send the project, but I'm doing, etc.
-
Aug 19th, 2012, 11:03 AM
#12
Re: Datagrid select error
 Originally Posted by Black_Trouble
need to be the exact opposite.
It can't be the exact opposite. Text is always string even when it's numbers!
Public Sub secelim()
Dim secelim As String = dgv.Rows(dgv.CurrentRow.Index).Cells(0).Value.ToString()
End Sub
-
Aug 19th, 2012, 11:31 AM
#13
Thread Starter
Lively Member
Re: Datagrid select error
-
Aug 19th, 2012, 11:53 AM
#14
Thread Starter
Lively Member
Re: Datagrid select error
I added the file. Can you take a look at
lookup control.rar
-
Aug 19th, 2012, 01:16 PM
#15
Thread Starter
Lively Member
Re: Datagrid select error
wonder if the result does not
-
Aug 19th, 2012, 03:52 PM
#16
Re: Datagrid select error
 Originally Posted by Black_Trouble
has failed again

This, dgv isn't even a control on your Main form...
Hover your mouse over the underlined regions and read the errors, otherwise open your error window and see what they say. This dgv_CellMouseClick isn't even Handling an event.
<<<------------
.NET Programming (2012 - 2018)
®Crestron - DMC-T Certified Programmer | Software Developer <<<------------
-
Aug 19th, 2012, 03:56 PM
#17
Thread Starter
Lively Member
Re: Datagrid select error
yes an event on the control. translated using English is not good. better placed to describe the sample. Can you help out the sample project.
-
Aug 19th, 2012, 03:57 PM
#18
Re: Datagrid select error
 Originally Posted by Black_Trouble
yes an event on the control. translated using English is not good. better placed to describe the sample. Can you help out the sample project.
I don't download projects from unknown sources, but I help on the individual code aspect of things. What does your errors window say? Copy them out and post them in your next reply, i'll show you what they mean.
<<<------------
.NET Programming (2012 - 2018)
®Crestron - DMC-T Certified Programmer | Software Developer <<<------------
-
Aug 19th, 2012, 03:58 PM
#19
Thread Starter
Lively Member
Re: Datagrid select error
ERROR
Reference to a shared member requires an object reference.
Code:
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Public Class hesap
#Region " text alan "
Protected Overrides Sub OnResize(ByVal e As EventArgs)
MyBase.OnResize(e)
Me.Button1.Left = (Me.MaskedTextBox1.Width - Me.Button1.Width)
End Sub
#End Region
#Region " Plan Tanıtım "
Protected Class hesapplani
Inherits System.Windows.Forms.Form
Private Mydgv As hesap
Private WithEvents dgv As System.Windows.Forms.DataGridView
Public Sub New(ByRef plan As hesap)
Mydgv = plan
Me.dgv = New System.Windows.Forms.DataGridView
Me.SuspendLayout()
Me.dgv.Location = New System.Drawing.Point(0, 0)
Me.dgv.Margin = New System.Windows.Forms.Padding(0)
Me.dgv.Name = "datagrid"
Me.dgv.TabIndex = 0
Me.dgv.Dock = DockStyle.Fill
Me.dgv.AllowUserToAddRows = False
Me.dgv.ReadOnly = True
Me.dgv.AllowUserToDeleteRows = False
Me.dgv.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing
Me.dgv.AllowUserToResizeColumns = False
Me.dgv.AllowUserToResizeRows = False
Me.dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
Me.dgv.RowHeadersWidth = 15
Me.dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(450, 614)
Me.ControlBox = True
Me.Controls.Add(Me.dgv)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable
Me.MaximizeBox = True
Me.MinimizeBox = True
Me.Name = "HesapPlanı"
Me.Text = "Hesap Planı"
'Me.ShowIcon = False
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.ResumeLayout(False)
End Sub
Private Sub hesapplani_Load(sender As Object, e As EventArgs) Handles Me.Load
If baglanti.State = ConnectionState.Closed Then baglanti.Open()
dategetir(dgv, "select kodu,adi from hesapplani")
baglanti.Close()
End Sub
Private Sub dgv_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgv.Click
hesap.MaskedTextBox1.Text = dgv.Rows(dgv.CurrentRow.Index).Cells(0).Value.ToString()
End Sub
End Class
#End Region
Private Sub MaskedTextBox1_GotFocus(sender As Object, e As EventArgs) Handles MaskedTextBox1.GotFocus
MaskedTextBox1.Select(0, 1)
End Sub
Private Sub MaskedTextBox1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles MaskedTextBox1.Resize
Me.Height = MaskedTextBox1.Height
End Sub
Private hesaplar As hesapplani
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If hesaplar Is Nothing Then hesaplar = New hesapplani(Me)
hesaplar.ShowDialog()
End Sub
End Class
Last edited by Black_Trouble; Aug 19th, 2012 at 04:02 PM.
-
Aug 19th, 2012, 04:07 PM
#20
Re: Datagrid select error
Since your class hesapplani is Interiting a form, and drawing a DataGridView on it from what it looks like, you need to reference the instance of hesapplani to access the datagridview control on that form.
<<<------------
.NET Programming (2012 - 2018)
®Crestron - DMC-T Certified Programmer | Software Developer <<<------------
-
Aug 19th, 2012, 04:08 PM
#21
Thread Starter
Lively Member
Re: Datagrid select error
I wanted to do this event. selected MaskedTextBox future. To do this I created the usercontrol.
-
Aug 19th, 2012, 04:10 PM
#22
Thread Starter
Lively Member
Re: Datagrid select error
 Originally Posted by AceInfinity
Since your class hesapplani is Interiting a form, and drawing a DataGridView on it from what it looks like, you need to reference the instance of hesapplani to access the datagridview control on that form. 
How do I make my teacher trying to make it up and down for a month. I did not get an answer from anyone.
-
Aug 19th, 2012, 04:23 PM
#23
Re: Datagrid select error
 Originally Posted by Black_Trouble
How do I make my teacher trying to make it up and down for a month. I did not get an answer from anyone.
Up down for a month? I'm confused.
I think the reason why you haven't been getting much help is not really your fault. It's more likely because people are having a hard time understanding what you want to do exactly through what you've been explaining thus far in this thread. I know for myself, that i'm having this particular issue right now as well, if others haven't already.
If you know what you want to do (I hope you do anyways lol), then as I've said, it's just as simple as using that instance to access the controls on that form to do stuff with them.
Example:
Code:
Dim frm1 As New Form1()
We don't use Form1 to access the controls, we use frm1 instead because it is the INSTANCE of Form1, not the Class Form1. Same principle with hesapplani.
<<<------------
.NET Programming (2012 - 2018)
®Crestron - DMC-T Certified Programmer | Software Developer <<<------------
-
Aug 19th, 2012, 04:32 PM
#24
Thread Starter
Lively Member
Re: Datagrid select error
I called many of the answer in the forum but no one answered. I do not understand where you need to attach this code to write. teacher if you can control from start to finish so that he can not tell you how grateful I'm going. I just started vb.net counted. but it's never been so helpless.
-
Aug 20th, 2012, 11:24 AM
#25
Thread Starter
Lively Member
Re: Datagrid select error
still not found a solution. Do not have anyone that can help
-
Aug 21st, 2012, 10:42 AM
#26
Thread Starter
Lively Member
Re: Datagrid select error
he looked up to people, but found a solution.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|