|
You write the code in procedure
Private Sub MyDatagrid1_RowHeaderMouseDoubleClick(...)
''write code of filling mainform Here
''u can refer to select items of datagrid by
Mainform1.textbox1=MyDatagrid1.item(0,e.rowindex).value
Mainform1.textbox2=MyDatagrid1.item(1,e.rowindex).value
.....
.
.
''Like this fill all items of mainform
end sub
As user clicks on rowheader of datagrid's specific cell ur code will be generated
if again any doubt , do ask.
I wnt to ask that , Is all of controls on mainform are textboxes?
priya
|
|
|
|
|
Hi,
thank you for your help. It is going good. I am almost done with my application except the one that I am asking.
yes. all the fields are textboxes on the main form. I am getting this error when I click on the one of the datagrid cells.
Unable to cast object of type 'System.String' to type 'System.Windows.Forms.TextBox'.
here is my code:
Private Sub FSSCallerRecordsDataGridView_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles FSSCallerRecordsDataGridView.CellContentClick
Form3.HospitalNumberTextBox = FSSCallerRecordsDataGridView.Item(5, e.RowIndex).Value
P.S. Form3 is the main form. And the reason I wrote Item(5) is that Hospital number on the datagrid is column number 5. (is it correct)
*****Is it necessary I can email you the project?
thanks, joseph
programmer
|
|
|
|
|
'Form3.HospitalNumberTextBox' should be ---> 'Form3.HospitalNumberTextBox.Text'
|
|
|
|
|
Hello, I have a simple question.
I'm a developer from 15 years to date, but with another languages.
Although i have a litle knowledge about vb, I didn't do nothing since VB 3.0.
Where I can find usefull information about programming in vb.net, I don't need to know how to make a "hello world" form.
I want to know how to connect to SQL Server, My SQL, Oracle, and other DB.
How to make a good bussines aplication ...
Well that's all by now!
Regards Nicolas
|
|
|
|
|
Google, or a good book, seem like the obvious answers. This is one of many sites with many, many example programs you can download and play with, and good quality articles full of info.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I agree with Christian.
One book comes to mind.
"An Introduction to Progamming Using Visual Basic.Net (Fifth Edition)
by David. I. Schneider."
That book comes with a cd full of examples
and I think also (but don't quote me on it) a 5 cd pack containing Visual Studio, MSDN libraries (and service pack 4 for the likes of win2k users).
Lots of examples are in the book and cd.
It covers multitude of concepts from "hello world" to complex accounting programs, and includes databases e.g. sequencial, relational, sql etc
and the use of datatables and datagrid etc
Published by Prentice Hall.
Cheers Rick
PS: The book also covers the concept and principles of class, polymorphism, inheritance and overriding. Schneider explains it well and the book is easy to follow.
These are a few of my favourite things...
Web Design - XHTML»CSS
Web Programming- JScript»JavaScript»XML»XSL»ASP.NET
Programming- 2d Games-GML»VB.NET
|
|
|
|
|
Thanks Christian and Richy, I will read some samples that I found on the net.
Im sure this site will give me al I need.
Best Regards from Argentina.
Nicolas Machado
|
|
|
|
|
Question I am using vb.net 2005. There is a form called login that has a data bound combobox. I am trying to pass that combobox back to my data tier, and extract the users selection using a query. i am unable to get the selected text from the combobox, however the textboxes login and logout work fine. i am able to update my access table once(with a blank for the combobox's value which is a primary key in the table)
I am un able to get the users selection from the combobox.
this is my data tier
Public Sub addLogIn(ByRef RefBindingSource As BindingSource, ByRef RefLogin As TextBox, ByRef RefLogOut As TextBox, ByRef RefPassword As TextBox, ByRef RefcboSalesRepsID As ComboBox)
MyAccountReceivableLogTableAdapter.InsertQueryComboBox(RefcboSalesRepsID.SelectedText, RefLogin.Text, RefLogOut.Text)
End Sub
and this is my form login:
Private Sub frmLogIn_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
MyLogDataSet = MyLogTableData.GetLogTableDataSet() ' a method in data tier, returns a data set
With MyBindingSource
.DataSource = Me.MyLogDataSet
.DataMember = "logtable"
.Sort = "sales rep id"
End With
With Me
With .cboSalesRepsIdLogInTab
.DisplayMember = "sales rep id"
.ValueMember = "sales rep id"
.DataSource = Me.MyBindingSource
.DataBindings.Add("text", MyBindingSource, "sales rep id", False, DataSourceUpdateMode.Never)
.SelectedIndex = 0
End With
.txtLogInInTab.DataBindings.Add("text", MyBindingSource, "log in", False, DataSourceUpdateMode.Never)
.txtLogOutInTab.DataBindings.Add("text", MyBindingSource, "log out", False, DataSourceUpdateMode.Never)
End With
Catch ex As Exception
End Try
End Sub
here is the calling method:
Private Sub btnPassWord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPassWord.Click
Try
MessageBox.Show(cboSalesRepsIdLogInTab.SelectedText)
MyLogin.addLogIn(MyBindingSource, txtLogInInTab, txtLogOutInTab, txtPassWord, cboSalesRepsID)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
|
|
|
|
|
hi,
Try one of Following->
MsgBox(cmbcust.Text)
MsgBox(cmbcust.SelectedItem)
MsgBox(cmbcust.SelectedText)
MsgBox(cmbcust.SelectedValue)
May it helps you, if not tell me wht error u get.
bye
priya
|
|
|
|
|
I have tried all of these and i get a blank messagebox. you have to access the data though the data set.
|
|
|
|
|
I tried the first one and it worked! i was confusing "selected text" with "text" thank you very much
|
|
|
|
|
I am trying to find out how to access the Graphics in the Preview Screen, when a screen saver is called with the /p #### option from the Display Properties Window for the screen, from the OS.
The ### passes back the handle to the Display Properties window, but how do I get from a handle to the actual window to manipulate it, or at least find its location so I can place graphics over the preview area?
The standard samples from C++ and C# don't seem to work if I try and translate them to VB.NET (2003)
Tom Verkaaik
|
|
|
|
|
I am writing code to clean a file and after the file is clean, I will get an exception saying
"object reference not set to an instance of an object". Any ideas?
Here is the code:
Private Sub CleanFilePF(ByVal File_Name As String, ByVal Temp_file As String)
Dim textline As String
Dim objReader As New System.IO.StreamReader(File_Name)
If System.IO.File.Exists(File_Name) = True Then
Do
textline = objReader.ReadLine
If textline.IndexOf("*") = 0 Then
Console.WriteLine(textline)
WriteFile(Temp_file, textline)
End If
Loop Until textline Is Nothing
If Not objReader Is Nothing Then
objReader.Close()
End If
End If
End Sub
When exception is thrown it highlights this line(If textline.IndexOf("*") = 0 Then)
Any suggestions would help!
jds1207
|
|
|
|
|
It's throwing an error because the file has been completly read and readline returns nothing. However, if textline is nothing then you are going to get an error if you try to use it like searching for the index of something. Try changing your Do Loop to
Do While Not objReader.EndOfStream
textline = objReader.ReadLine
If textline.IndexOf("*") = 0 Then
Console.WriteLine(textline)
WriteFile(Temp_file, textline)
End If
Loop
|
|
|
|
|
I have an access DB with a table named "Note" in it. The DB is linked to a VB.net interface. I did a form so that when a value is selected from a combo box, in a grid are displayed all the related records (ex: i choose a library from the combo box and in the grid are displayed all the reader that are subscribed to that library). One form is working, but another one that involves a table named "note" displays the " Syntax error in form clause" error message.
What a want ask is: Could it be because of the table name? Is "note" a reserved word?
10x
==========================
Be positive, it helps...
==========================
|
|
|
|
|
doubtful. if it is a keyword, wrap it in square brackets like [note]
Posting your select would also help us
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Here is the code from the "SelectedIndexChanged" procedure:
Private Sub cboDenLoc_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboDenLoc.SelectedIndexChanged
OleAdpNote.SelectCommand = New _
System.Data.OleDb.OleDbCommand("SELECT * from Note where matricol = '" & cboDenLoc.SelectedValue & "'")
OleAdpNote.SelectCommand.Connection = OleConexiune
DsNoteleStudenti1.Tables("Note").Clear()
OleAdpNote.Fill(DsNoteleStudenti1, "Note")
End Sub
==========================
Be positive, it helps...
==========================
|
|
|
|
|
My first question would be what is returned by cboDenLoc.SelectedValue?? Is it something that is "SQL Safe"?? Probably not. For example, what if the SelectedValue returned soemthing with a quote mark in it? It'll invalidate your SQL statement and cause an error like you're getting.
You might want to consider using a parameterized query so that anything entered is escaped properly.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello,
I have an VB.NET application and need to edit attahment before sending it.
Here is my current code which sends email automatically using outlook.
But I need to open outlook first, in case attachment needs to be edited by user.
Does anyone know how to do it? thanks, Joseph
' Create an Outlook application.
Dim oApp As Outlook._Application
oApp = New Outlook.Application()
' Create a new MailItem.
Dim oMsg As Outlook._MailItem
oMsg = oApp.CreateItem(Outlook.OlItemType.olMailItem)
oMsg.Subject = "Termination Notification,Final Check Needed"
oMsg.Body = "Termination Notice For Final Payroll Check" & vbCr & vbCr
' Replace with a valid e-mail address.
oMsg.To = "Joseph.Kacan@banfield.net"
' Add an attachment
' Replace with a valid attachment path.
Dim sSource As String = "\\M1Data02\josephk$\Data\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\TermReport.rtf"
' TODO: Replace with attachment name
Dim sDisplayName As String = "Termination.rtf"
Dim sBodyLen As String = oMsg.Body.Length
Dim oAttachs As Outlook.Attachments = oMsg.Attachments
Dim oAttach As Outlook.Attachment
oAttach = oAttachs.Add(sSource, , sBodyLen + 1, sDisplayName)
' Send
oMsg.Send()
' Clean up
oApp = Nothing
oMsg = Nothing
oAttach = Nothing
oAttachs = Nothing
programmer
|
|
|
|
|
Hi, I am trying to return the directories in a computer using the below syntax but i can't seem to find an appopriate string path. Getdirectories seems only to return the subdirectories of a certain string path e.g: "c:\". What i want to to retrieve ALL the directories in the computer without having point them out. If this functions isn't want i should be using then what else? Thank in advance...
Dim strArray()As String
strArray = System.IO.Directory.GetDirectories("???")
System.IO.File.WriteAllLines("c:\directories.txt", strArray)
MessageBox.Show(System.IO.File.ReadAllText("c:\directories.txt"))
|
|
|
|
|
Just a thought but I would say that you would need to look at the root and save all of the directories in some kind of dictionary object like an array, then cycle through that array and look in each of those directories deeper and deeper until there are no directories left.
Cleako
|
|
|
|
|
You need to recurse into each of the directories.
Create a method that adds all the directories in the passed in directory to the list. For each new directory the method calls itself with the newly discovered directory. Eventually your array will be full of directories.
|
|
|
|
|
Thanx for all the suggestions, it seems i should write the code myself. I thought there was a built in function that would do this operation on it's own
|
|
|
|
|
turtle1010 wrote: it seems i should write the code myself
That's what seperates programmers from script-kiddies.
turtle1010 wrote: I thought there was a built in function that would do this operation on it's own
Nope. Just about any library, like the .NET Framework, will offer you simple classes and methods that you use to build more complex classes, like using the GetDirectories method to build your own version of a more complex GetDirectoryTree method, like you're describing.
Noone, and God know Microsoft has a hell of a time doing this, can predict and supply every tool for you for your every need. There has to come a time where you must write the code that seperates your application from every other one that does that same thing.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Maybe something like this.
You call the method and pass in a DirectoryInfo object that is created with the root path (e.g. C:\), or any path, and it will return all the subdirectories from there. The catch it to handle the exception where you are not permitted into a subdirectory.
public static List<DirectoryInfo> GetSubdirectories(DirectoryInfo directory)
{
List<DirectoryInfo> result = new List<DirectoryInfo>();
DirectoryInfo[] childDirectories;
try
{
childDirectories = directory.GetDirectories();
}
catch (UnauthorizedAccessException uae)
{
Debug.Print(uae.Message);
return result;
}
foreach (DirectoryInfo childDirectory in childDirectories)
{
result.Add(childDirectory);
List<DirectoryInfo> grandchildDirectories = GetSubdirectories(childDirectory);
result.AddRange(grandchildDirectories);
}
return result;
}
|
|
|
|