|
I just had that same problem. Here is an example:
<br />
' Draw all font names on form<br />
Dim gr As Graphics = Me.CreateGraphics<br />
gr.Clear(Color.White)<br />
<br />
' Prepare a message with tabs and carriage returns.<br />
Dim msg As String = String.Format("{0}Column 1{0}Column 2{0}Column 3{1}" _<br />
& "Row 1{0}Cell (1,1){0}Cell (1,2){0}Cell (1,3){1}" _<br />
& "Row 2{0}Cell (2,1){0}Cell (2,2){0}Cell (2,3){1}", _<br />
ControlChars.Tab, ControlChars.CrLf)<br />
Dim fnt As New Font("Arial", 12)<br />
<br />
Dim strFormat As New StringFormat()<br />
' Set the tab stops.<br />
Dim tabStops() As Single = {80, 140, 200}<br />
strFormat.SetTabStops(0, tabStops)<br />
' Draw the text with specified tab stops.<br />
gr.DrawString(msg, fnt, Brushes.Black, 20, 20, strFormat)<br />
<br />
fnt.Dispose()<br />
gr.Dispose()<br />
<br />
Hope that hels you!
|
|
|
|
|
Hi,
Does anybody know where I can find some information on Database
access/update/delete through VB.NET
I'm creating a program with multiple forms, which needs to select,add,delete
record from an ACCESS DB.
It is my first DB project and I'm totally lost...
Any help I would greatly appreciate it...
Thank you,
CJ
|
|
|
|
|
Hello CJ. Ok i am new too in vb.net and i had such a problem to find a solution with Access and VB.NET. BUT i found the answer that you are looking for too. Here it is:
************************* Searching in a database:
Dim strConnection As String = OleDbConnection1.ConnectionString
(the connectionString will be a string created from the VB when you specify where your database is)
Dim connect As New OleDbConnection(strConnection)
Dim test As String
Dim te As String
Dim SQLString As String
connect.Open()
te = txtAreaToSearch.Text
SQLString = "SELECT * from informations WHERE Area =" & "'" & te & "'"
Dim cmd As New OleDbCommand(SQLString, connect)
Dim reader As OleDbDataReader = cmd.ExecuteReader()
While reader.Read()
txtCouncilName.Text = reader.GetValue(1) 'gets the value of the first attribute in your databse eg postCodeOfTheArea
End While
reader.Close()
connect.Close()
In this example you will need a OleDbConnection1 and a OdbcCommand1 objects. Also the following must be put at the start :
Imports System
Imports System.Data
Imports System.Data.OleDb
What the example does is to search in a database on the TABLE informations for an AREA with the name that is in a TEXTBOX called txtAreaToSearch.
********************************** Deleting an entry
Dim SQLStringUpdateKeys As String
Dim SQLStringUpdateArea As String
Dim icount As Integer
Dim icount1 As Integer
Dim strConnection As String = OleDbConnection1.ConnectionString
Dim connect As New OleDbConnection(strConnection)
Dim inputOption As Integer
inputOption = MsgBox("Are you sure you want to delete this record", MsgBoxStyle.OKCancel, "Are you sure?")
If inputOption = 1 Then
connect.Open()
On Error Resume Next
SQLStringUpdateArea = "DELETE FROM informations WHERE Area = '" & txtAreaName.Text & "'"
Dim cmd1 As New OleDbCommand(SQLStringUpdateArea, connect)
icount1 = cmd1.ExecuteNonQuery
connect.Close()
MessageBox.Show("Records Deleted in table: " & icount1)
Else
Exit Sub
End If
************************* inserting a new entry
Dim SQLStringUpdateKeys As String
Dim SQLStringUpdateArea As String
Dim icount As Integer
Dim icount1 As Integer
Dim strConnection As String = OleDbConnection1.ConnectionString
Dim connect As New OleDbConnection(strConnection)
connect.Open()
On Error Resume Next
SQLStringUpdateKeys = "insert into informations values('" & txtKeyWordUp.Text & "','" & txtAreaNameUp.Text & "')"
Dim cmd As New OleDbCommand(SQLStringUpdateKeys, connect)
cmd.ExecuteNonQuery()
icount = cmd.ExecuteNonQuery
connect.Close()
connect.Dispose()
MessageBox.Show("New records added in table: " & icount)
Hope this helps.
Still trying to find the way
|
|
|
|
|
Wow, I was way off..
Let me give this a try... thank you "Chaos Machine"
|
|
|
|
|
Drop an OleDbDataAdapter on a form and use the wizard to connect to the access DB and select a table that you want to view and it will auto-generate all the select, insert, delete and updates for the table. Right click the OleDbDataAdapter and choose Generate DataSet. Add a DataGrid to your form and set the DataSource and DataMember for the DataGrid in the properties Grid. ON the form load event add:
Me.OleDbDataAdapter1.Fill(DataSet1) '<-- Assuming you used the default autogenerated names.
I suggest reading thru MSDN and just search using DataSet, DataView, BindingManager, BindingManagerBase, CurrencyManager, Calculated Column, Strongly Typed DataSet. You'll need to know what all these things are if you are ever to make anything work. MSDN & Google is your best source really for learning just lookup those words.
Don't buy the Book "Programing MicroSoft VisualBasic.Net For MicroSoft Access Databases", it's absolute garbage.
Use the "DataForm Wizard" by selecting File|Add new item and look at how it builds a form with navigation buttons.
I've been learning all this over the last few weeks, and I must say it's quite FUSTRATING to say the least. It shouldnt be this hard to connect to data and work with it without using third party solutions.
I've been playing with the 2005 vb.net Beta and It looks like it's going to be much much easier to work with.
|
|
|
|
|
Thank you...
VB is supposed to be this easy to learn, "foolproof" language...Its not!
|
|
|
|
|
nyjcr wrote:
VB is supposed to be this easy to learn, "foolproof" language...Its not!
It's not that the language is hard to learn, IMHO it's not and neither was C++, C#, Java, COBOL, Intel x86 Assembler, TI 9900 Assembler, FORTRAN, ... It's learning how to string together a bunch of statements that makes sense and does what you want that's the hard part. This is true for ANY language.
|
|
|
|
|
nyjcr wrote:
VB is supposed to be this easy to learn, "foolproof" language...Its not!
.Net has made so many thing with VB much easier than previous versions, with the exception of connecting to a plain ol Access database. I miss using vb6 only for data, but im really starting to get the hang of ADO.Net and am starting to like it.
|
|
|
|
|
I have searched now for 3 hours, it is time 2 ask some people if it is posible. My question: I have a project for school and I made an awsom cartoon illustration for the application, but the app needs some textboxes ass wel. But I don't want to let the illustration get behind the textbox so you can't see it anymore.
Is ther a way to set the alpha of an textbox to 50% or sow? So that both are visible? That would be very nice. I have tryed some things bud nothing seems to work. Opacity works only with the form, Transparency Key doesn't work for me because if I set it 2 white, you can't see the box anymore but you can see right trough my programm, sow that is not what I want.
Are ther some people who know if this is posible and how to do this?
Sory for my English.
|
|
|
|
|
Can I use multiple resource files in VB? It seems that the IDE will only let me work with one...
Thanks,
Tim
|
|
|
|
|
I am using the XMLDocument class to extract a specific node's data and then replace it with different data. This is done successfully but when I save the file the second line is modified to contain "[]" after the dtd declaration.
The first two lines of the XML file looks like this before I run my code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE POWERMART SYSTEM "powrmart.dtd">
After running my code the first two lines look like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE POWERMART SYSTEM "powrmart.dtd[]">
The following is a bare-bones section of my code:
Dim xd As New Xml.XmlDocument
xd.XmlResolver = Nothing
'Load the xml file
xd.Load(filepath)
'Find the Element Node (INSTANCE)
Dim NodeList As Xml.XmlNodeList
Dim Node As Xml.XmlNode
NodeList = xd.DocumentElement.GetElementsByTagName("INSTANCE")
For Each Node In NodeList
If Not Node Is Nothing Then
'Find the Attribute of this element ("TRANSFORMATION_NAME")
TransformationName = Node.Attributes.GetNamedItem("TRANSFORMATION_NAME").Value
'Set the new Attribute of the element("TRANSFORMATION_NAME")
NewTransformationName = "NEW_NAME"
' Write the new TransformationName
Node.Attributes.GetNamedItem("TRANSFORMATION_NAME").Value = NewTransformationName
' Reset node to nothing
Node = Nothing
End if
Next Node
xd.Save(filepath)
For some reason when this saves to XML it modifies the DOCTYPE line to add a [] at the end of the .dtd expression, and I don't know why. If anyone could help I would greatly appreciate it.
|
|
|
|
|
I am interested in someone providing a sample that has a panel on a user control that contains a collection of controls available at design time. To put it simply I would like the following.
1. a user control
2. a panel control
3. a collection of, let's say, label controls that are accessible at design time that are contained on the panel
I understand the method to add a collection, or any control, to the properties window is <designerserializationvisibility(designerserializat ionvisibility.content)="">. What I don't understand is 1. How to create the collection of controls and where to place the <designerserializationvisibility(designerserializat ionvisibility.content)="">. 2. How to place the controls on the Panel at design time.
BTW, I haven't found this simple example on any of the forums. I think Microsoft should provide a decent example of this.
A little extra information to clarify the need. I need a user control containing a panel with a collection of controls where the user control has the collection exposed in it's property window when it is dropped on a form. This will be much like the grid control, which has a columns property in it's property window. When the user clicks on the ellipse '...' an editor pops up where you can add and remove columns and set their properties.
|
|
|
|
|
Anonymous wrote:
I was trying to use two DataReaders. I guess I need to use two DataSets?
The number of DataSets is not the problem. You can only have one active DataReader object on a connection and any one time. You can have multiple DataSets filled by a DataReader, though.
Anonymous wrote:
"mySqlConnection.Open()"
at the top of my Sub() and close at the bottom. Is this ok?
Not really. You should .Open() your connection immediately before your fill the DataSet , or do whatever you need to do with the database, then .Close() the connection as soon as your done with it. DON'T leave it open and idle for ANY reason. This needlessly consumes resources on the SQL server, not to mention hogs a very expensive licensed connection on the server too.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks for all your help!
|
|
|
|
|
It sounds funny, but is there any way to hide
checkbox from checkbox control?
|
|
|
|
|
I meant by program. off course I can just put another
control on top of it to hide.
|
|
|
|
|
CheckBox.Hide() should work.
|
|
|
|
|
Sorry this is in vb.
And I just want to hide checkbox only but not label
|
|
|
|
|
|
So make the checkbox and the label two separate objects.
|
|
|
|
|
The thing is I want to display chinese, japanese, English on this control
only the control can do this is checkbox otherwise i have to install
Microsoft Form 2.0 ObjectLibrary. Since Microsoft won't allow you to distribute this library with your application, I don't want to do.
It only works if you have office installed on your computer.
|
|
|
|
|
hello
im a new VB.NET user
i know there are a lot of thread bout this but
i really need a small example on how to update, delete and add
data to database
i have only 1 textbox...with 3 button(delete, add n update)
with a database name TRY
i dont need much..just a small fragment of code...
i read similiar thread before..but it is very confusing to me
please help me
thank you in advance
Gary
|
|
|
|
|
Hi,
I'm trying to bind the text property of a combobox to a property of one of my objects that is accessed using an index but I can't quite find the right way to make it work. I tried this:
<br />
MyComboBox1.DataBindings.Add(New Binding("Text", Settings.Item(0), ""))<br />
MyComboBox2.DataBindings.Add(New Binding("Text", Settings.Item(1), ""))<br />
MyComboBox3.DataBindings.Add(New Binding("Text", Settings.Item(2), ""))<br />
Which will correctly read the value from the object, but for some reason it doesn't get written back? Any ideas?
Thanks
WJ
|
|
|
|
|
Just a guess, but maybe the item you're binding TO is not allowed to be indexed. Here's a convoluted hack we have to use to get around the NULL problem with binding combos (but that's another story).
1) create an offscreen textbox (note that it can't be an on-screen textbox with the Visible property set to false (Yes, that's another story too).
2) have your object keep that textbox popuplated
3) then bind your combo to the text property of the offscreen textbox.
In your example, you'll need three offscreen textboxes.
Good Luck
john
|
|
|
|
|
Hi!When one writes more lines than the richtext visible area a scroll automatictly shows up, but it doesn't keep up with the text that is being written.I would like it to always be at the bottom, showing the latest writes.Isn't there any property or value that can be changed?I can't seem to find it.All i saw in the web was some strange confusing code with handlers and stuff... :P
Thanks in advance.
|
|
|
|
|