|
Well what I want to do is; When the user selects an item in the ListBox, the PictureBox loads a file from the resources and displays it, and when the user selects another item, the PictureBox do the same procedure but gets another picture.
Since I've never used code to grab something from the resources, I have no clue on where and how I'm gonna load them. A friend of mine gave me this[^] link where it was described how a PictureBox could be used.
pictureBox1.Image = _<br />
new Bitmap(Assembly.GetExecutingAssembly(). _<br />
GetManifestResourceStream("PictureBoxControl.tinyemulator_res.jpg"))
The issue with this is that first Assembly is undefined and second that, well I have no freakin' idea on where the UI input should be. Is that enough to help me?
Cheers!
|
|
|
|
|
First do you have Imports System.Reflection at the beginning of your code, you need that to access the Assembly object. For the next part use the ListBox SelectedIndexChanged event, use the selecteditem value to index your resource file.
Hope that helps
|
|
|
|
|
Please check this link out http://msmvps.com/blogs/JayHarlow/default.aspx[^] It can give you an idea. If I were you, I would use embeded resources of course it is much easier to deal.
Also here is another approach:
<code>
The following example uses the ResourceManager.GetObject method to retrieve and display a binary resource (such as a graphic image).
…
Dim private rm As ResourceManager
rm = New ResourceManager("MyImages", Me.GetType().Assembly)
PictureBox.Image = Ctype(rm.GetObject("MyObject"), System.Drawing.Image)
…
</code>
-- modified at 16:24 Monday 12th March, 2007
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
im creating a form where users can login to a seperate form using a login name and password. I'm trying to compare the users imput for the login to a feild in MS Access and the same with password input in a seperate feild in the same table(PCBank.mdb). if input is correct go to form2.
if anyone can help it would be greatly appreciated. code below is my attempt
Imports System.Data.OleDb
Public Class Form1
Dim conn As OleDbConnection
Dim comm As OleDbCommand
Dim dr As OleDbDataReader
Dim da As OleDbDataAdapter
Private Sub connect()
conn = New OleDbConnection
conn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=|datadirectory|\PCBank.mdb"
conn.Open()
comm = New OleDbCommand
comm.Connection = conn
comm.CommandType = CommandType.Text
End Sub
Private Sub DisplayRecord()
Me.txtid.Text = dr.GetString(0)
Me.txtpass.Text = dr.GetString(1)
End Sub
Private Sub btnlogin_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click
connect()
comm.CommandText = "select * from Managers where id like '" & txtid.Text & txtpass.Text & "%'"
If txtid.Text = "Managers" = dr.GetString(0) And txtpass.Text = "Managers" = dr.GetString(1) Then
My.Forms.Form2.Show()
Me.Close()
End If
End Sub
End Class
|
|
|
|
|
peteyshrew wrote: Dim conn As OleDbConnection
Dim comm As OleDbCommand
Dim dr As OleDbDataReader
Dim da As OleDbDataAdapter
Why would you make these members ?
peteyshrew wrote: comm.CommandText = "select * from Managers where id like '" & txtid.Text & txtpass.Text & "%'"
You're truncating the username and password in to one string and using LIKE. What you should be doing is doing a select that checks if a record exists with exactly the username and password that were entered, so the real username and password never get pulled out of the database.
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 have have not look at this in detail but does not msaccess require you use "*" as a wild card instead of the SQL "%"/
jhoga
|
|
|
|
|
I have hierarchical data that the user can make one of four choices about. The primary treeview manages @900 rows of data that collapsed to @100 groups.
I need to draw a tree view with a 'radio button group' where the radio buttons are related to the treeview node index.
I have made a User Control for the 4 radio button but can't quite figure out:
1) How to Position the radiobuttons to align with the tree view node
2) Linkage to connect the button data to the treeview node
i.e.
[a,b,c,d] tvNode1
[a,b,c,d] tvNode2
Each control is located on separate panels, panel 1 is for the radio buttons, panel 2 is for the Treeview. - Is there may be a better way???
TIA
Tom Hamilton
Sacramento, CA
|
|
|
|
|
I would start from an existing treeview control and set the the DrawMode-property to OwnerDrawAll, so you you don't have to bother about the complexicity of the positions. In this mode you can draw your buttons instead of the existing signs in the treeview. Does this help your problem?
|
|
|
|
|
In vb.net 2005.
I am wanting to say at form load that if a global value (strName) has not been used (i.e. has not been entered into), then load another form, how can i do this, i have tried:
If strName.length < 1
strName.Empty
Help!!!
|
|
|
|
|
better delete this one...you'll get yelled at for double posting
|
|
|
|
|
try this Code
If strName= Nothing Then
else
End If
|
|
|
|
|
Sorted now cheers
|
|
|
|
|
In vb.net 2005.
I am wanting to say at form load that if a global value (strName) has not been used (i.e. has not been entered into), then load another form, how can i do this, i have tried:
If strName.length < 1
strName.Empty
Help!!!
|
|
|
|
|
Public Class Common
public shared strName as string = String.Empty
End Class
Public Class Form1
private sub form_load(....)
if common.strname = string.empty then
common.strname = "hello"
End if
End Sub
End Class
|
|
|
|
|
I want to clarify what you are asking? Are you trying too check the value of a textbox control to see if it is null and if so then opening a different form? Or are checking to see if a control has been createded?
Jhoga
|
|
|
|
|
Im trying something like this:
If strName.IsNullOrEmpty Then frmTeachBasics.Show()
The strName is a global, but it is coming up with an error asking me to replace "strName with String"
|
|
|
|
|
Try If String.IsNullOrEmpty(strName) Then frmTeachBasics.Show
|
|
|
|
|
i have two forms , form 1 and form 2
if have given some value in textbox1 of form1, i want the same value to be displayed on label of form2...
please help..
thanks
|
|
|
|
|
you can pass the pointer of the label of form1 to form2 and have it update in the textchange event or leave event.
|
|
|
|
|
You should NEVER pass a reference to a control between forms. You can pass the string to form2, via a property, store the value in a common property in a static class, or use a delegate to inform form2 when it changes in form1, if form2 is modeless.
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 )
|
|
|
|
|
im creating a form where users can login to a seperate form using a login name and password. I'm trying to compare the users imput for the login to a feild in MS Access and the same with password input in a seperate feild in the same table(PCBank.mdb). if input is correct go to form2.
if anyone can help it would be greatly appreciated. code below is my attempt
Imports System.Data.OleDb
Public Class Form1
Dim conn As OleDbConnection
Dim comm As OleDbCommand
Dim dr As OleDbDataReader
Dim da As OleDbDataAdapter
Private Sub connect()
conn = New OleDbConnection
conn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=|datadirectory|\PCBank.mdb"
conn.Open()
comm = New OleDbCommand
comm.Connection = conn
comm.CommandType = CommandType.Text
End Sub
Private Sub DisplayRecord()
Me.txtid.Text = dr.GetString(0)
Me.txtpass.Text = dr.GetString(1)
End Sub
Private Sub btnlogin_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click
connect()
comm.CommandText = "select * from Managers where id like '" & txtid.Text & txtpass.Text & "%'"
If txtid.Text = "Managers" = dr.GetString(0) And txtpass.Text = "Managers" = dr.GetString(1) Then
My.Forms.Form2.Show()
Me.Close()
End If
End Sub
End Class
|
|
|
|
|
in my form i hv strDbDate as string which ic coming from txt file and in database it is stored in varchar2 format
eg strDbDate = 20070212 which is in format yyyymmdd
now i want to check dis date is valid or not
Public Function CheckDate(ByVal strDate As String) As Boolean
Dim formatNew As New CultureInfo("en-GB")
Dim sDate As Date
Try
If sDate = DateTime.ParseExact(strDate, "yyyyMMdd", formatNew) Then
Return True
Else
Return False
End If
Catch ex As System.Exception
RemarksLabelUC1.RemarksText = "Invalid date format"
Return False
End Try
End Function
if anybody knows plzzz reply ASAP
thnxs
|
|
|
|
|
You can also use the IsDate function. I think you'd first have to reorganize the string to this format first MM/dd/yy and then you can say:
If IsDate(strDbDate) Then<br />
Return True<br />
Else<br />
Return False<br />
End If
|
|
|
|
|
Why not just do this:
Return IsDate(strDbDate)
But, the problem with IsDate is that it won't let you specify a format for the date string, which if read one way is perfectly legal, but if it's not system default format, isn't legal.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|