|
And then how do you explain that a form with size 968x610 goes outside a screen 1024x768 ?
Speaking for form's size the width 968 is greater than 1024(when speaking for screen resolution ) ?
|
|
|
|
|
You would first have to produce some evidence that a form that is smaller than the screen is displayed bigger than the screen.
Speed of sound - 1100 ft/sec
Speed of light - 186,000 mi/sec
Speed of stupid - instantaneous.
|
|
|
|
|
I have no idea what your system is setup like, such as setting a custom scaling level in the Display control panel, but normal the form if set to 968x610 WILL BE 968x610.
|
|
|
|
|
I always design for the smallest reasonable screen size. I used to have a graphic as my background that displayed the sizes from 640 - to 1024 but that was a long time ago. Now I make sure my forms fit a 13" laptop at 1024.
I then use a dock type layout where the central control (commonly the gridview) is expandable to fill the area when the user maximises the form.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello !
I'm using vb.net 2013 and Entity Framework 6
I need to implement the INotifyPropertyChanged
I've done that by manually changing the classes.But I have problems , because every time that I make changes on my database , the "update model from Database" on visual studio is almost unusable , so I have to re-create from the beginning the Model.edmx.But after that , all that I wrote for implementing InotifyPropertyChanged is lost , so I have to make from the beginning.
Is there any easy way to do that ?
Thank you !
|
|
|
|
|
This article may help[^]
It's in C#, but you can use a convertor to translate it to VB, such as the one from Telerik[^].
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Hello !
I'm using vb.net 2013 and entity Framework 6.
I'm trying to save a new object and a child object like this :
MyObject ---- id , nm , value
ChildObject ---- id , name , vl , MyObjectID ( Foreign key related with id on MyObject )
Dim obj1 as Myobject
Dim child1 as ChildObject
obj1=new MyObject
obj1.nm="123"
obj1.value=25
obj1.ChildObjects=New List(of ChildObject)
child1=new ChildObject
child1.name="abc"
child1.vl="efd"
obj1.ChildObjects.Add(child1)
context.MyObjects.add(obj1)
Context.SaveChanges
After this code , the obj1 is saved on database , but the child1 is not saved. No error messages.
What can I do ?
|
|
|
|
|
Show the code that defines the Myobject and ChildObject. I'm suspicious of the code that adds a NEW list of ChildObject.
|
|
|
|
|
Partial Public Class MyObject
Public Property id As Integer
Public Property nm As String
Public Property valu As Integer
Public Overridable Property ChildObjects As ICollection(Of ChildObject) = New HashSet(Of ChildObject)
End Class
Partial Public Class ChildObject
Public Property id As Integer
Public Property name As String
Public Property vl As String
Public Property MyObjectID As Integer
Public Overridable Property MyObject As MyObject
End Class
|
|
|
|
|
OK, in your first code snippet, you do NOT new up a List object. You use the existing HashSet object you created in your MyObject class:
Using context As New MyObjectContext
Dim obj1 As New MyObject
obj1.nm = "123"
obj1.value = 25
Dim child1 As New ChildObject
child1.name = "abc"
child1.vl = "efd"
obj1.ChildObjects.Add(child1)
context.MyObjects.Add(obj1)
context.SaveChanges()
End Using
You also do not need the Public Property MyObjectId As Integer line in the ChildObject class definition. EF will create this field automatically:
Public Class ChildObject
Public Property id As Integer
Public Property name As String
Public Property vl As String
Public Property MyObjectId As Integer <-- remove this line
Public Overridable Property MyObject As MyObject
|
|
|
|
|
Sorry , but if a remove the line MyObjectID , how can I create the relationship between 2 tables in sql server ?
|
|
|
|
|
I already told you, EF takes care of that for you.
|
|
|
|
|
Sorry , because i'm using Database-First and I create the edmx file with wizard from an existing database. I'v tried to do what you are saying , and after I have created the model , these 2 tables are not related and ChildObjects Property does not even exist on MyObject.
|
|
|
|
|
I though you were using Code First. In your case, you have to leave the field in.
In Code First, you don't have to put that field in your model because EF will create and use the field automatically.
|
|
|
|
|
Do While sFolderName <> ""
For i = 0 To dirList.ListCount - 1
w = 1
hIcon = ExtractAssociatedIcon(App.hInstance, "C:\Windows", 3)
If sFolderName <> "" And sFolderName <> "" Then
If (GetAttr(sPath & sFolderName) And vbDirectory) = vbDirectory Then
ListView2.ListItems.add , , sFolderName, Picture2.Picture
Picture2.AutoRedraw = True
Picture2.Cls
DrawIcon Me.Picture2, 0, 0, hIcon
End If
If IsNull(hIcon) Then
picBuff.Picture = Picture2.Picture
Else
End If
sFolderName = Dir
End If
Next
ListView2.Icons = imgFiles
ListView2.SmallIcons = imgFiles
Loop
|
|
|
|
|
Hello all,
This might be a slightly basic question, but I'm trying to get into the head of a previous developer and where they were going with some unfinished code. I apologize if this is vague, but it's all I've got to work with.
Here is what I'm looking at, I've got a User Interface element that implements an interface. I'm confused as to why one would implement a Sub from an interface within a Sub in the UserInterfaceElement like this.
Any ideas?
Public Class UserInterfaceElementClass
Implements IEditableElement
Protected Sub SetupElement() Implements IEditableElement.SetupElement()
End Sub
Protected Sub UpdateObjectFromElement() Implements IEditableElement.UpdateObjectFromElement()
End Sub
End Class
Public Interface IEditableElement
Sub SetupElement()
End Sub
Sub UpdateObjectFromElement()
End Sub
End Interface
|
|
|
|
|
hilli_micha wrote: I'm confused as to why one would implement a Sub from an interface within a Sub in the UserInterfaceElement like this.
Because that's how interfaces work. I'm confused by your confusion.
An interface doesn't provide any implementation. It simply declares a contract for a type.
A class which implements the interface must provide an implementation of every member of that interface. In VB.NET, the implementation of the interface member is indicated by the Implements InterfaceName.MemberName after the member declaration.
Any class which implements an interface can be passed to any parameter, property, variable or method return declared as that interface type.
Interfaces (Visual Basic)[^]
Walkthrough: Creating and Implementing Interfaces (Visual Basic)[^]
Advantage of using Interface and Inheritance in VB.NET (OOP)[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm not sure if I understood your question in the right way.
Is your question to ask for the sense of the implements-call on the method ... like answered by Richard ?
Or is your question to asked for the possible sense of in this case unused interface-method's ?
If you ask for the 2nd then it could be possible that another class could identify this class (or control) by using Reflection without knowing it's definate Type.
Perhaps you should be more specific ...
|
|
|
|
|
Ralf and Richard,
Thanks for replying. I just wanted to update you and let you know that my confusion stemmed from a lack of understanding on interfaces in themselves. I've since familiarized myself a bit better and have a grasp on the issue I was having.
Thanks!
|
|
|
|
|
Hi,
I am using Visual Studio 2010 and programming in vb. I have a txtbox name "txtFirstName" and a button called "btnCommit". Once the user has added a name to FirstName and clicked the button I need the programme to check the access database tabel to see if the name exists or not. How do I go about doing this?
Thank you in advance for your assistance.
Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDb.OleDbConnection
Dim inc As Integer
Dim MaxRows As Integer
Dim dbProvider As String
Dim dbSource As String
Dim MyDocumentsFolder As String
Dim TheDatabase As String
Dim FullDatabasePath As String
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
TheDatabase = "/AddressBook.mdb"
MyDocumentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
FullDatabasePath = MyDocumentsFolder & TheDatabase
dbSource = "Data Source = " & FullDatabasePath
con.ConnectionString = dbProvider & dbSource
con.Open()
sql = "SELECT *FROM tblContacts"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "AddressBook")
con.Close()
MaxRows = ds.Tables("AddressBook").Rows.Count
inc = -1
End Sub
Private Sub NavigateRecords()
txtFirstName.Text = ds.Tables("AddressBook").Rows(inc).Item(1)
txtSurname.Text = ds.Tables("AddressBook").Rows(inc).Item(2)
cboxHouse.Checked = ds.Tables("AddressBook").Rows(inc).Item(3)
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
If inc <> MaxRows - 1 Then
inc = inc + 1
NavigateRecords()
Else
MessageBox.Show("No More Rows")
End If
End Sub
Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
If inc > 0 Then
inc = inc - 1
NavigateRecords()
ElseIf inc = -1 Then
MessageBox.Show("No Records Yet")
ElseIf inc = 0 Then
MessageBox.Show("First Record")
End If
End Sub
Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click
If inc <> MaxRows - 1 Then
inc = MaxRows - 1
NavigateRecords()
End If
End Sub
Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click
If inc <> 0 Then
inc = 0
NavigateRecords()
End If
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("AddressBook").Rows(inc).Item(1) = txtFirstName.Text
ds.Tables("AddressBook").Rows(inc).Item(2) = txtSurname.Text
ds.Tables("AddressBook").Rows(inc).Item(3) = cboxHouse.CheckState
da.Update(ds, "AddressBook")
MessageBox.Show("Data updated")
End Sub
Private Sub btnAddNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddNew.Click
btnCommit.Enabled = True
btnAddNew.Enabled = False
btnUpdate.Enabled = False
btnDelete.Enabled = False
txtFirstName.Clear()
txtSurname.Clear()
txtFirstName.Focus()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
btnCommit.Enabled = False
btnAddNew.Enabled = True
btnUpdate.Enabled = True
btnDelete.Enabled = True
inc = 0
NavigateRecords()
End Sub
Private Sub btnCommit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCommit.Click
If inc <> -1 Then
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("AddressBook").NewRow()
dsNewRow.Item("FirstName") = txtFirstName.Text
dsNewRow.Item("Surname") = txtSurname.Text
dsNewRow.Item("House") = cboxHouse.CheckState
ds.Tables("AddressBook").Rows.Add(dsNewRow)
MaxRows = MaxRows + 1
MessageBox.Show("New Record added to the Database")
btnCommit.Enabled = False
btnAddNew.Enabled = True
btnUpdate.Enabled = True >
btnDelete.Enabled = True
btnCommit.Enabled = False
btnAddNew.Enabled = True
btnUpdate.Enabled = True
btnDelete.Enabled = True
inc = 0
da.Update(ds, "AddressBook")
NavigateRecords()
End If
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
If MessageBox.Show("Do you really want to Delete this Record?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.No Then
MessageBox.Show("Operation Cancelled")
Exit Sub
End If
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("AddressBook").Rows(inc).Delete()
MaxRows = MaxRows - 1
inc = 0
da.Update(ds, "AddressBook")
NavigateRecords()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Application.Exit()
End Sub
End Class
|
|
|
|
|
Just query the database for a record that contains the entered name.
|
|
|
|
|
Thank you for your response.
How do I go about doing this. I am not good at coding...
|
|
|
|
|
Member 12816539 wrote: I am not good at coding Then now would be a good time to study the documentation for the database you are using. Especially commands to insert, update and select records.
|
|
|
|
|
Hello !
In a vb.net 2013 application , I have a treeview when I need to have drag and drop operations .
But I have a case when the user begin to drag , but before drop to destination node I need to test something and if a condition is false , the entire operation should undo .
How can I do this ?
Thank you !
|
|
|
|
|
It would be easier if you showed your code, so hope this helps.
The normal process is in the DragEnter event you set e.effects = to the drag and drop you will allow (move, copy etc). Then in the DragDrop event determine your condition and set e.Effect = DragDropEffects.None if it is not allowed, else execute the drop code.
|
|
|
|