|
I have a textbox control whose multiline property is set to true.
I have some text in that textbox control.
For the first time I printed those textbox content program through my program.
And secondly, when i copy that exact same content in the notepad, and printed it,it prints differently.I want to print those textbox content like the printing from the notepad.
Do I have to change any setting in the textbox property so that the textbox content will be printed
in the same way that the notepad prints?
I think notepad automatically formats the spacing but the textbox control doesnot.So the textbox content doesnot print in the format that i want.
I printing using the code:
..........
e.Graphics.DrawString(txtPrnt.text, New Font("Tahoma", 8, FontStyle.Regular), Brushes.Black, e.MarginBounds.X, e.MarginBounds.Y)
...........
|
|
|
|
|
I am not very clear as what differences you see, however there would definitely be some difference between the print taken from an application like notepad and from a control like textbox.
Any text editor has codes written behind it to format text before it is sent to the printer. Therefore if you need any specific type of formatting in text, you should –
1) Take text value of text box in a string object.
2) Perform whatever formatting you want on this string by writing your code.
3) Send this string object to the printer.
I hope this clarifies the scenario.
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
As per this article[^] you need to pass a [b]StringTrimming[/b] class to the Graphics.DrawString call to get the text to wrap appropriately.
|
|
|
|
|
In my program I have alot of objects that are linked together directly and indirectly sort of like a database. I want to use serialization to save these objects.
My question is when I tell it to serilize the object will it serialize just that object or will it also serilize objects that it is directly or indirectly linked to? And if the answer is the latter does this mean I would end up with duplicate copies being saved of the same object if I save more than 1 entry point for this group of objects?
thanks,
Mike
|
|
|
|
|
This depends on which version of .NET you're using. Under .NET 1.x, you'll have to write your own serializer. This is easy considering there are hundred examples of it all over the web. All you have to do is Google for "VB.NET serialize linked list" to find them.
Under .NET 2.0, this is even easier if you use the generic LinkedList class for your collections. It's already serializable and can be used with the existing .NET serialization classes.
|
|
|
|
|
Is it possible to amend, add and delete the items of a listbox during runtime?
|
|
|
|
|
|
ListBox is one of those Controls that offer an Items collection, which you can
use and abuse at all times.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Especially abuse. In situations i never even imagined.
|
|
|
|
|
I have managed to change the TabPage Color but I don't know how to change the background color of TabControl. I tried to put following code in Form paint event but still I coudn't remove the grey color of Tab Control.
For Each ctr As Control In frm.Controls
If TypeOf ctr Is TabControl Then
Dim rect1 As New Rectangle(ctr.Location.X, ctr.Location.Y, ctr.Width, ctr.Height)
Dim brush As New SolidBrush(Color.Green)
grph.FillRectangle(brush, rect1)
End If
Next
I would appreciate for your help.
Nas
|
|
|
|
|
There is no such direct way of setting backcolor property of Tab Control. However after setting DrawMode property of tab control to OwnerDrawFixed, we may draw tab control using our custom code.
Put following line of code on form load event –
Me.TabControl1.DrawMode = TabDrawMode.OwnerDrawFixed
Put following code in DrawItem event of Tab control-
----------------------Code Start---------------
Private Sub TabControl1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles TabControl1.DrawItem
Dim f As Font
Dim backBrush As Brush
Dim foreBrush As Brush
If e.Index = Me.TabControl1.SelectedIndex Then
'''''If its the tab page which is selected
f = New Font(e.Font, FontStyle.Regular)
backBrush = New System.Drawing.Drawing2D.LinearGradientBrush(e.Bounds, Color.AntiqueWhite, Color.LightSkyBlue, System.Drawing.Drawing2D.LinearGradientMode.Vertical)
foreBrush = Brushes.Black
Else
'brush for unselect tab pages
f = e.Font
backBrush = New SolidBrush(e.BackColor)
foreBrush = New SolidBrush(e.ForeColor)
End If
Dim tabName As String = Me.TabControl1.TabPages(e.Index).Text
Dim sf As New StringFormat
sf.Alignment = StringAlignment.Center
''''Draw tab rectangle
e.Graphics.FillRectangle(backBrush, e.Bounds)
Dim r As RectangleF = New RectangleF(e.Bounds.X, e.Bounds.Y + 4, e.Bounds.Width, e.Bounds.Height - 4)
'Draw text of tab pages
e.Graphics.DrawString(tabName, f, foreBrush, r, sf)
sf.Dispose()
If e.Index = Me.TabControl1.SelectedIndex Then
f.Dispose()
backBrush.Dispose()
Else
backBrush.Dispose()
foreBrush.Dispose()
End If
End Sub
---------------------Code End---------------
I hope this helps.
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Hello.
I'm working on an problem for an week now and i'm getting nowhere.
When I make an setup and deploy it on another PC i can't use the Access database.
The error that i get is:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Data.OleDb.OleDbException: No error message available, result code: -2147024770(0x8007007E).
at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbConnection.Open()
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at Test_VBiB.TestDatabaseDataSetTableAdapters.tNamenTableAdapter.Fill(tNamenDataTable dataTable)
at Test_VBiB.oAccessData.oAccessData_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Test_VBiB
Assembly Version: 0.0.0.0
Win32 Version: 0.0.0.0
CodeBase: file:///C:/Program%20Files/EwR%20Development/Setup/Test_VBiB.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Data
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Data.SqlServerCe
Assembly Version: 3.5.0.0
Win32 Version: 3.5.5386.0
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Data.SqlServerCe/3.5.0.0__89845dcd8080cc91/System.Data.SqlServerCe.dll
----------------------------------------
System.Transactions
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitdebugging="true">
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
I hope someone can help me.
I've been looking on the internet for this week and can't find any thing that should help me.
Thanks.
Erich.
(Dutch).
|
|
|
|
|
Hi Man
Is the Computer of the Client has .NET installed ?
Try to Install Microsoft Data Access Components 2.7 on that Computer, i have been using Access as my back-end but i have never came across a Problem.
Hope it helps
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hi.
Sorry to say but that was not the solution.
I've installed MDAC 2.7 and still I'm getting the same error.
The most frustrating about this all is that the error message says that there is no message.
<br />
System.Data.OleDb.OleDbException: No error message available, result code: -2147024770(0x8007007E).<br />
I expect that if something goes wrong VB lets me know WHAT goes wrong.
Hope you got some more info and an solution.
Thanks a lot.
|
|
|
|
|
It appears to be bombing out making a connection to the database, so I'd probably start looking at the connection string. Maybe the setup put the database where your code isn't looking?
|
|
|
|
|
I don't understand what you mean by 'It appears to be bombing out making a connection to the database,'.
That kind of English is an bit to difficult for me.
I'm dutch.
Maybe you got an bit of code to show me what you mean.
My App.Config looks like this:
<
connectionStrings>
<add name="Access_DB_2.My.MySettings.TestDatabaseConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Data\TestDatabase.mdb;Persist Security Info=True"
providerName="System.Data.OleDb" />
</connectionStrings>
>
I also thought that would be an problem so i changed my VB code on the load event to this:
<br />
Dim oDa As New OleDb.OleDbDataAdapter("SELECT * FROM tNamen", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Data\TestDatabase.mdb;Persist Security Info=True")<br />
Dim oDt As New DataTable<br />
Dim oBs As New BindingSource<br />
<br />
oDa.Fill(oDt)<br />
oBs.DataSource = oDt<br />
<br />
Try<br />
DataGridView1.DataSource = oBs<br />
<br />
Catch ex As OleDbException<br />
MsgBox(ex.Message)<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
Finally<br />
oDa = Nothing<br />
End Try<br />
But that was not an solution.
The directory my Program is installed in is: c:\program files\EwR Development\Access DB 2.
And the database is in: c:\program files\EwR Development\Access DB 2\data
The images are located in: c:\program files\EwR Development\Access DB 2\Images
If you need my project I'll send it to you in an zip/rar file.
If you need de setup i can send it to you to. Also in an zip or rar file.
|
|
|
|
|
Erich Rebel wrote: 'It appears to be bombing out making a connection to the database,'.
That kind of English is an bit to difficult for me.
The code throws an exception...
Erich Rebel wrote: Data Source=|DataDirectory|\Data\TestDatabase.mdb;
Erich Rebel wrote: And the database is in: c:\program files\EwR Development\Access DB 2\data
If the code runs in the debugger, I'd check to see if your installation actually did put the database in the correct folder under Program Files. If it's there, open it up in Access and make sure it has the same schema you expect it to have.
|
|
|
|
|
Finally my problem is gone.
On the target PC I've made an new install of Windows XP and everything works fine now.
I was so tired of everything going wrong and had done so many thinks trying to make it work that i didn't see any other solution.
And it works.
Looks like my target PC was too full of sh*t and couldn't work any more.
Thanks for your help anyway.
|
|
|
|
|
When a multithreaded application hits a breakpoint do all threads stop or just the one that hit the breakpoint? If the first one is true then what happens to the other threads when you step through your code?
thanks,
Mike
|
|
|
|
|
|
I am building an application using two forms. On form1 I have a list box, and two text boxes, one for a string and the other for an integer.
Form2 has two text boxes and a button. When the button is clicked, I would like the data (string and integer) diplayed in the textboxes on form2 to be displayed in the listbox on form1.Also when the item is selected in the listbox, I would like the string and integer to be displayed in the relevant textboxes on form1.
Please help..
|
|
|
|
|
roger6897 wrote: Please help..
With what? You haven't provided any code. Or are you expecting someone to do your work for you?
Read the MSDN documentation to learn about the properties and methods exposed by the textbox and listbox controls. Attempt to solve the problem yourself and post again if you have more specific questions.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
pmarfleet wrote: you expecting someone to do your work for you
Probably.
Hence my sig which was quoted by Pete O'Hanlon.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
I have two forms. One is used to add data and the other to view that data.
The first form is used to add items to a listbox (on the first form). How can those items be added to the second form, so that they are available in the combo listbox on the second form?
|
|
|
|
|