|
No. You'll have to find a Math library that supplies the functions you want or write them yourself. No, I don't know of any... try Google.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I want to connect datagrid with a datareader.
dim dr as datareader
--
---
datagrid1.datasource = dr
it is not working...
A sample code will be more helpful.
Thanks
Suman Singh
|
|
|
|
|
You can't do that. If you read the docs for the DataSource[^] property, you'll find that it works with any DataTable, DataView, DataSet, or DataViewManager objects, or any object that implements the IListSource or IList interfaces. DataReader is not one of them.
You use the DataReader object to fill a DataSet, then you can bind the DataSet to the DataGrid as a DataSource.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
check the code I inserted (bold line) You declare the datareader, and you set the data grid source to that, but you never assign any data to the data reader. Hope this helps!
dim dr as datareader
dr=datasource (from spreadsheet, or database, or whatever)
datagrid1.datasource = dr
|
|
|
|
|
Hi,
I am trying to read a formatted data file using streaReader from a simple project which has three forms. When I type the statement, it says variable (streamReader) not defined. Imports system.io statement is there in first form code. I would appreciate any clues.
Thanks
amanjot
|
|
|
|
|
You should import system.io in each form on which you going to create object for streamreader...
Suman Singh
|
|
|
|
|
Since you only imported the System.Io namespace on the first form, you can only use it's classes on the first form. If you want to use the StreamReader class on you 2nd and 3rd forms, each of them will also have to import the System.Io namespace.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i want that my application should start whenever the computer starts how to do that
ddd
|
|
|
|
|
Build your application as a Windows Service. The MSDN has a walkthrough.
|
|
|
|
|
I have two forms.Clicling the button on form 1 Leads to Form 2 by hiding Form 1.I have submit (button) and Cancel(button) on Form2.When I hit Cancel.Form2 needs to be closed and open form1.Any help will greatly be appreciated.
Thanks
|
|
|
|
|
On the cancel button you should use the following code:
unload me
form1.show
this code will unload the form2 and show the form1.
You can use the same code on the form1 when u shifts from form1 to form2. you will only change form2.show.
|
|
|
|
|
It says "unload me" not declared.Can you tell me what I am supposed to do?
Thanks,
|
|
|
|
|
It could be because "unload me" is VB6 syntax...
You might just want to try "me.hide" to hide a form.
Hope this helps,
Mitch
My sig:
"And it is a professional faux pas to pay someone else to destroy your computer when you are perfectly capable of destroying it yourself." - Roger Wright
Get Perpendicular! (Hitachi Storage)
My CodeProject Blog
Most recent blog post: April 11
|
|
|
|
|
form2.hide/form1.show (or the reverse - depending on which one you want visible), or you can use the visible property
form1.visible = true
form2.visible = false
Note that these do not clear the forms from memory, just make them invisible to the end user at runtime
|
|
|
|
|
I have CrystalReport TextObject and I want to assing in its text property a string variable. My string variable is created with the code:
For i = 0 To n-1
str1 = str1 & i + 1 & ". " & vbnewline
Next
My problem is that I cannot display the string in the textobject as it is.
Although I use the vbnewline (enter) the textobject is displaying the string in one row.
Could you please help me.
Thanks in advance
|
|
|
|
|
I creat a button with image menually, like below
Dim aImageButton As New Button
tpgContact.Controls.Add(aImageButton)
aImageButton.Name = entity
aImageButton.Text = ""
aImageButton.Image = Image.FromFile("C:\vb.net\client\images\checkbox_checked.gif")
aimagebutton.ImageAlign = ContentAlignment.MiddleCenter
aimagebutton.FlatStyle = FlatStyle.Flat
aImageButton.Location = New Point(10, y)
aImageButton.Width = 20
aimagebutton.Height = 20
AddHandler aImageButton.Click, AddressOf ImageButtonClickHandler
the problem I have in here is "aImageButton.Image = Image.FromFile("C:\vb.net\client\images\checkbox_checked.gif")" this line of code. If the app install in other computer, then it won't be able to find the same location. What should I do? Is there any way to change the location to fix the need?
Lisa
|
|
|
|
|
There are (2) things you should know about using File Paths:
1) Don't EVER hard code path's like you did in this statement.
2) Don't EVER assume the file is in the "Current Directory" or "Working Directory". Always use fully qualified paths to files.
Right now, you're probably trying to figure out how to use a fully qualified path without knowing what that path is???
Easy. What you should be doing is building a path using a "known" location as a reference. The Application.StartupPath property will tell you from which folder your .EXE was loaded, or launched, from. If your .GIF file is in the same folder as your .EXE, you have a "known" starting point. All you have to do now is build the complete path to the file.
But wait a minute! Most beginners will use string concatenation to do this. Something like:
Dim myGifFile As String = Application.StartupPath & "\myGifFile.GIF"
Don't EVER do this! Instead, use a class that's specifically designed to do this, and more, using the proper path seperation characters and build rules for the platform that it's running on. The Path class does just this. Specifically, what you're looking for is:
Dim myGifFile As String = Path.Combine( Application.StartupPath, "myGifFile.GIF" )
Path.Combine takes (2) arguments. The first being the beginning of the path and the second being the ending. You don't have to worry about prepended or appended path seperation characters either. Path.Combine will take care to make sure that the path it generates is in a legal format.
Assuming that your .GIF image is in the same folder as the .EXE, your code should look more like this:
' Build a new button control
Dim aImageButton As New Button
With aImageButton
Dim imagePath As String = Path.Combine( Application.StartupPath, "checkbox_checked.gif" )
.Image = Image.FromFile( imagePath )
.Name = entity
.Text = ""
.ImageAlign = ContentAlignment.MiddleCenter
.FlatStyle = FlatStyle.Flat
.Location = New Point(10, y)
.Width = 20
.Height = 20
End With
' Attach the Click Event handler
AddHandler aImageButton.Click, AddressOf ImageButtonclickHandler
' Finally, add the control to the form
tpgContact.Controls.Add(aImageButton)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks..that's so helpful...
I have another issue in my vb app. here is my coding:
private function contactView()
'connect to data and do the query.....
'user the DataReader to read the value from the query...
'Query: SELECT primary_contact, entity_id from Conatcts
Do While DR.Read()
primaryContact = DR.GetBoolean(0)
entity = DR.GetInt32(1)
'creat a image button
If primaryContact = True Then
Dim aImageButton As New Button
With aImageButton
Dim imagePath As String = Path.Combine(Application.StartupPath, "checkbox_checked.gif")
.Image = Image.FromFile(imagePath)
.Name = entity
.Text = ""
.ImageAlign = ContentAlignment.MiddleCenter
.FlatStyle = FlatStyle.Flat
.Location = New Point(10, y)
.Width = 20
.Height = 20
End With
' Attach the Click Event handler
AddHandler aImageButton.Click, AddressOf ImageButtonclickHandler
' Finally, add the control to the Form
tpgContact.Controls.Add(aImageButton)
Else
Dim aImageButton As New Button
With aImageButton
Dim imagePath As String = Path.Combine(Application.StartupPath, "checkbox_blank.gif")
.Image = Image.FromFile(imagePath)
.Name = entity
.Text = ""
.ImageAlign = ContentAlignment.MiddleCenter
.FlatStyle = FlatStyle.Flat
.Location = New Point(10, y)
.Width = 20
.Height = 20
End With
' Attach the Click Event handler
AddHandler aImageButton.Click, AddressOf ImageButtonclickHandler
' Finally, add the control to the Form
tpgContact.Controls.Add(aImageButton)
End If
y += 25
Loop
end function
Public Sub ImageButton1ClickHandler(ByVal sender As Object, ByVal e As System.EventArgs)
results = CType(CType(sender, Button).Name, Int32)
Dim DA As New OleDbDataAdapter
objConn.Open()
DA.SelectCommand = New OleDbCommand
DA.SelectCommand.Connection = objConn
DA.SelectCommand.CommandType = CommandType.Text
DA.SelectCommand.CommandText = "UPDATE Contacts set primary_contact = 0 WHERE client_entity_id = " & client_entityID
DA.SelectCommand.ExecuteNonQuery()
Dim DA2 As New OleDbDataAdapter
DA2.SelectCommand = New OleDbCommand
DA2.SelectCommand.Connection = objConn
DA2.SelectCommand.CommandType = CommandType.Text
DA2.SelectCommand.CommandText = "UPDATE Contacts set primary_contact = 1 WHERE entity_id = " & results
DA2.SelectCommand.ExecuteNonQuery()
objConn.Close()
End Sub
---here is my problems, after the click, I want to rebind the data, so the form will show up the change, I can't recall the function in the ImageButton1ClickHandler, what should I do?
Lisa
|
|
|
|
|
Lisana wrote:
I can't recall the function in the ImageButton1ClickHandler, what should I do?
If you want to call the code in the handler, just move the code to another method outside the handler.
Public Sub ImageButton1ClickHandler(ByVal sender As Object, ByVal e As System.EventArgs)
Dim results As Int32 = CType(CType(sender, Button).Name, Int32)
BindDataSources(results)
End Sub
Public Sub BindDataSources(ByVal entityID As Int32)
' I'm assuming client_entityID is a "global" variable
objConn.Open()
Dim DA As New OleDbDataAdapter
DA.SelectCommand = New OleDbCommand
With DA.SelectCommand
.Connection = objConn
.CommandType = CommandType.Text
.CommandText = "UPDATE Contacts set primary_contact = 0 WHERE client_entity_id = " & client_entityID
.ExecuteNonQuery()
End With
Dim DA2 As New OleDbDataAdapter
DA2.SelectCommand = New OleDbCommand
With DA2.SelectCommand
.Connection = objConn
.CommandType = CommandType.Text
.CommandText = "UPDATE Contacts set primary_contact = 1 WHERE entity_id = " & entityID
.ExecuteNonQuery()
End With
objConn.Close()
End Sub
Now you can call BindDataSources from anywhere in your code, so long as you provide it an entityID.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I think you misunderstood my meaning, I want to call the function contactView not the update query.
Public Sub ImageButtonClickHandler(ByVal sender As Object, ByVal e As System.EventArgs)
results = CType(CType(sender, Button).Name, Int32)
contactView() 'give me error
end sub
it gave me error when I call the contactView() in the ImageButtonClickHandler
The main thing I want to do in here is when the blankImageButton Click, then go the database to change the pimary_contact to 1, the other pimary_contact=1 to 0, at the same time, the button image changes as well, in the output, the imagebutton didn't change when I click, but the database is updated. I have to close the window, then reopen again, then it shows the change.
Lisa
|
|
|
|
|
Whopps! My mistake.
What's the error?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The main thing I want to do in here is when the blankImageButton Click, then go the database to change the pimary_contact to 1, the other pimary_contact=1 to 0, at the same time, the button image changes as well, in the output, the imagebutton didn't change when I click, but the database is updated. I have to close the window, then reopen again, then it shows the change.
Lisa
|
|
|
|
|
You've got a major design flaw in there. Every time you call contactView, you're created new buttons. But, you're never removing the old ones that you created.
What are you trying to do with the buttons? Implement paging?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How can I remove the old buttons when before contactView() called?
those buttons are checked and unchecked buttons, if you have 5 contacts, there is only one pimary contact that would be the checked buttons, if you want to change your pimary contact, then click one unchecked button, the one you just clicked will become the pimary contact(changed to checked button), the old pimary contact changed to unchecked button.
like this:
-Unchecked X checked
5 lists, when the second record click, then
old new
- -
- X
- -
X -
- -
Lisa
|
|
|
|
|
If there is some compelling reason whay you absolutely have to add the buttons at run-time - like the numebr of buttons changes depending on the number of contacts, then load them all one time when the form is initialized. After you create each button, also add it to a local collection.
Then when a person clicks on a button, enumerate the local collection, set each button's state to unchecked, then continue to process the click event to perform the query and reset the newly checked contact.
This will be much faster than trying to constantly add and remove buttons and their event handlers from the form. You also do not need to keep track of the current state of any given button, because you simply reset them all to unchecked whenever one is clicked.
Unless you have a lot of buttons, simply enumerating the list will be about as fast, and much simpler than writing code to keep track of the the button state.
Robert
|
|
|
|
|