|
Thanks Dave for your reply ..
Really I'm waiting you and you for reply ,, and I still rememper you every day and rememper your words ,, God bless you !
I'm sorry that I mean on this line
DataGridView.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Col1, Col2, Col3, Col4})
I want to understand what i mean , see , I'm using Master/Details form,
and I did an ides which when the user add or edit then I copy the details records to a temp table , then after that when save the program copy all recors from temp taple to Base table , is idea is good on many sides ,, I see that,
from that I change the DataSource and DataMember of DataGridView , then I found that the order and header text of columns is changed , then I try to solve that problem by that , on every action the program clear all columns an reAdd it with it's propertis that I need , then the Problem that I entioned it on first message faced me ,, I hope you see ,,
jooooo
|
|
|
|
|
I suggest straightening out your column code and create then add each column as you make it. Oh! For future posts, copy and paste the actual code you're using. DO NOT RETYPE IT in the post yourself. You're more likely to cover up the problem with other mistakes if you do.
Private Sub AddCol()
Dim newCol As New DataGridViewTextBoxColumn ' NOT DataGridViewColumn!
newCol.DataPropertyName = "Field1"
newCol.HeaderText = "Col1"
newCol.Width = 40
DataGridView1.Columns.Add(newCol)
newCol = New DataGridViewTextBoxColumn
newCol.HeaderText = "Col2"
newCol.Width = 40
DataGridView1.Columns.Add(newCol)
....
End Sub
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
|
I'm having a problem printing (i'm really sending it a string in its own language) to a shared network printer.
I have written the following code:
Dim idFile As Integer = FileSystem.FreeFile
FileSystem.FileOpen(idFile, "\.0.0.1\ZebraLP2844", OpenMode.Append, OpenAccess.Write, OpenShare.Shared)
strTemp = "N" & vbCrLf 'Clear Buffer
strTemp = strTemp & "q816" & vbCrLf 'Label Width in dots (4 inches?)
strTemp = strTemp & "Q203,24+0" & vbCrLf 'Label Height and gap in dots (1 inch)
strTemp = strTemp & "S2" & vbCrLf 'S = Speed Select
strTemp = strTemp & "D10" & vbCrLf 'D = Density
strTemp = strTemp & "ZT" & vbCrLf 'Direction set to forward? (ZT is what u want)
strTemp = strTemp & "OD" & vbCrLf 'Direct Thermal Mode
strTemp = strTemp & "A25, 12, 0, 5, 4, 2, N, """ & myName & """" & vbCrLf
strTemp = strTemp & "LO50, 5, 800, 20" & vbCrLf
strTemp = strTemp & "A75, 12, 0, 5, 4, 2, N, """ & mySN & """" & vbCrLf
strTemp = strTemp & "P" & numCDPrint.Value().ToString & vbCrLf
FileSystem.Print(idFile, strTemp)
FileSystem.Reset()
But on line:
FileSystem.FileOpen(idFile, "\.0.0.1\ZebraLP2844", OpenMode.Append, OpenAccess.Write, OpenShare.Shared)
I Recieve this error message:
"FIleStream was asked to open a device that was not a file. For support for devices like 'com1:' or 'lpt1:', call CreateFile, then use the FileStream constructors that take an OS handle as an IntPtr."
I'm converting an Old VB6 project to VS.NET. This code in VB6 works with no problem:
Open "\.0.0.1\ZebraLP2844" For Output As #1
strTemp = "N" & vbCrLf ''' Clear buffer
strTemp = strTemp & "q811" & vbCrLf ''' Label Width in dots (2 inches)
strTemp = strTemp & "Q1217,1" & vbCrLf ''' Label height and gap in dots (1 inch)
strTemp = strTemp & "S" & Trim(Me.strSpeed) & vbCrLf
strTemp = strTemp & "D" & Trim(Me.strDensity) & vbCrLf
strTemp = strTemp & "ZT" & vbCrLf ''' Direction
strTemp = strTemp & "OD" & vbCrLf ''' Direct Thermal mode
strTemp = strTemp & "A25,12,0,4,1,1,N,""" & sFirstLine & """" & vbCrLf
strTemp = strTemp & "A25,45,0,4,1,1,N,""" & sSecondLine & """" & vbCrLf
strTemp = strTemp & "A25,78,0,4,1,1,N,""" & sThirthLine & """" & vbCrLf
strTemp = strTemp & "P" & Trim(intQty)
''' End of the EPL2 code
Print #1, strTemp
Close
Any help on how to send this stream/string/file to my shared printer using VS.NET would be greatly appreciated!!
|
|
|
|
|
You can't use the File Stream objects to do this. They can only be used on actual files.
You're looking for something more like this[^] example.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I need a way to tell if 2 images are the same. more specifically, i need to know if 2 screen shots taken less than one second apart are the same or are different. I have tryed using the Image1.Equals(Image2) but this apparently just compares objects and not the data contained with in them. I found some obscure code on sourceforge, but im not sure i will be able to convert it to do what i want it to do. Also I am assuming that if i take 2 screen shots and nothing on the screen has changed, that the 2 resulting images should be identical pixel for pixel. I could be wrong on this part, but i have no way to test this as of yet. suggestions please.
|
|
|
|
|
My image processing articles show how to access the bits of a bitmap. Then it's a snap to iterate over them and see if any have changed.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
ok so i am making a program with VB 2005 Express Edition and an Access database connected to it. when i run the program in the IDE it works fine but when i install it and run it, it talks about not being able to find the database. Now my question is... when you make a program with a database in the resource file, isn't the program supposed to copy to database to where ever it is supposed to read from and if it isnt then where\how to i get the program to copy and read the database upon installation. Also, i am keeping on the back burner the fact that when i install the program i want to be able to go into the database and change information and/or be able to print reports on the data.
the error:
upon startup the program cannot find the database and is looking in a folder that the program creates on its own(i didnt programmably make it)
the folder:
c:\Documemts and Settings\myUser\Local Settings\Apps\2.0\Data\993YD61J.131\C9JHJHC1.JGY \star..tion_8549497152147e43_0001.0000_603d66f8611c4d37\Data\Resources\
now why would it be looking there of all places and how can i correct this problem, this tis the knowledge i seek! lol
thanks
Joshua
|
|
|
|
|
You have to include the .MDB file in the installation project and make sure that it get's placed in the folder that your app is expecting. There is nothing that does this automatically. It's just another file, like you app's .EXE, that you're responsible for in the install.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Ok so how would i add it i mean im using VB 2005 Express and i dont know if thats even an option, if it is i cant find it. Id ont think they give you a lot of options in the free version. anyone know a good How To on attach a data to an installation file?
|
|
|
|
|
Well, I played with ClickOnce for a little bit. It doesn't look like you can add the extra file. I actually have no idea if you can or can't. I don't use ClickOnce for any of my deployments.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Is there a way to make all children forms see the MDI left as anything other than 0. For instance if I wanted to make all child forms left=150, is there a way to set a property of the MDI form to 150.
|
|
|
|
|
'routine in the mdi
Sub ChangeLocation(iLeft as int16)
For Each ChildForm As Form In Me.MdiChildren
ChildForm.left = iLeft
Next
end sub
|
|
|
|
|
Is there a way to make all children forms see the MDI left as anything other than 0. For instance if I wanted to make all child forms left=150, is there a way to set a property of the MDI form to 150.
|
|
|
|
|
Nope. You can change the left edge of the MdiClient control that your child forms are rendered in though. Search the MDI Parent forms Control container for the only control that is an MdiClient. You can then make anyn changes you want to it, just like any other control you drag and drop on the form. By default, the MdiClient is Docked to Fill the form it's on, so in order to change it's location, you'll have to set it's Dock property to None. Then you'll be able to change Location and Size properties.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I have been looking around the net and the examples are so generic I am having trouble following them. I have taken over code that contains a class that calls .NET Interop code, so this is present.
<br />
Public Class ClassName<br />
Implements System.IDisposable<br />
<br />
Public Sub Dispose() Implements System.IDisposable.Dispose<br />
<br />
End Sub<br />
That is it in terms of the Dispose code in the class. What do I need to add to this to make it useful and do I need it at all?
Thanks,
Cleako
|
|
|
|
|
this is good information:
http://www.codeproject.com/useritems/idisposable.asp
|
|
|
|
|
Man, I do alot of coding but when it comes to the Dispose calls I just dont get it. That page is like a math book giving an example of an equation such as y=2x+b then the 1st problem you get is 2-y=x^81 + b/4 or some other nonsense.
In other words that sounds great and I get when to put object.Dispose but I guess Im unsure what objects require a Dispose call and which ones dont and when do I actually call Dispose and when does the code do it for me?
Cleako
|
|
|
|
|
If the Dispose method is empty, you don't need it. Dispose is used when an object needs to clean up resources, like unmanaged file handles and such or managed objects that your object holds onto that don't clean themselves up, like a Graphics object. You put the code in the Dispose method that cleans these "loose ends" up before your object is destroyed.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
cleako wrote: I guess Im unsure what objects require a Dispose call
Any objects that hold resources of significant size, or resources that are unmanaged ( such as GDI handles )
cleako wrote: when do I actually call Dispose
That bit is easy - when you are about to lose access to an object, either because it's a local variable, or you're about to change the value ( or, you may set a value to null after calling Dispose on the basis that you don't need it anymore )
cleako wrote: when does the code do it for me?
Never. The code will call Finalise when it finally GCs the object. I don't think that Dispose is ever called by the framework. Really, your code should use finalise as well, and clean up anything there that was not Dispose'd of.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I used to call .Dispose on objects all the time then I asked a trainer about it and they made it sound like I was doing too much. So 2 more questions then.
What is a good resource other than that page I was pointed to read up on this stuff and when should I do something like .Dispose and when should I do something like Implements IDisposable etc...?
Cleako
|
|
|
|
|
As a general rule of thumb, you call .Dispose on object that implement it.
You implement IDisposable on your own object when they have resources that you need to specifically release when your done with them.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
rules to live by:
1) if an object has a dispose method, you should ALWAYS call it or bad things like memory leaks can occur
2) "try" to never rely on vb to clean up your objects for you.
3) add a dispose method to your classes and call it to safely release(close,dispose,nothing) all of your objects.
4) in routines, try to utilize they key word "using" which is supposed to guarantee (according to the help file) proper release of memory that your object was taking up.
|
|
|
|
|
So if I have a class for DataAccess and I call it just to make the connection and return a dataset, should I also have a .Dispose in that class that disposes of the Connection Object everytime and any data adapters etc...?
Cleako
|
|
|
|
|
You should be closing your database connection when you're done with the SQL query. NEVER hold open an SQL connection longer than is absolutely necessary. SQL server licenses are expensive. Holding a connection open for the life of your application hogs that license so no other application can use it when you're not using it. Remember, Windows and Servers are SHARED resources, so you have to write your code to work and play nice with others.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|