|
Everyone new to the .NET Framework see's this and freeks out. It's normal! You don't (and CAN'T) do anything about it.
If you minimize the app and restore it, you'll see that your application seemingly dumps alot of this memory. In reality, it's not. What's going on is that you've got the weight of the .NET Framework under your application. When you minimize your app, alot of your code and data (whether it's part of your app or part of the Framework) gets swapped out to disk and no longer resides in physical RAM. When you restore the app, only the code and data that's needed immediately gets swapped back to RAM. As you use your application, more data and code is swapped back and forth to the pagefile as needed.
If the Garbage Collector sees that there is plenty of RAM to run your application, it might not swap this stuff out and free up RAM. Why waste the time, if it's really not necessary? Only when RAM starts to run low will the garbage collector be more aggressive swapping code and data out to disk and cleaning up objects that aren't in use any more.
Don't panic! Just let the Garbage Collector do it's job!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the quick response. I originally thought it was due to my application.
Thanks,
Programmer2k4
My sig:
"The so-called 'Bugs' do not exist, they are merely features hidden by developers with message boxes that say 'An unhandled exception has occurred'." - Programmer2k4
"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
I now use my CodeProject Blog!
|
|
|
|
|
Hi everyone,
I'm trying to find out if there is a way to apply Microsoft's Word formatting features to a textbox in .NET and be able to save and the retrieve the field to SQL server without loosing any of the formatting set. Does anyone know if this is possible? I would appreciate any comments or suggestions. Thanks so much!
Tasha
|
|
|
|
|
No, the TextBox doesn't support any formatting. The RichTextBox does, but on a much smaller scale than Word's formatting capabilities. Since the RTF formatting codes are in-line with the text, all you have to do to save everything is get the RichTextBox.Rtf , which returns a String, and save that to your database.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi,
in vb.net i have a form which contains 2 buttons and some text fields. the user may enter the data in text fileds in the following format.
ex. "have a #nice# day". some of the words may be prefixed and suffixed with the # symbol. now when user presses the first button i want to store these data(dataset) to the rtf or text file.
when the user presses the 2nd button, i want to open the same text or rtf file and then i want to format the file in such a way that. all the #(hash) delimited words should be italisized and the file has to be save.
so anyone pls. help me.
thanks in advance
thiru.
|
|
|
|
|
Help you with what? So far, you haven't asked a question we can answer. You'll have to be specific about what part of your application you need help with and what the problem is.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I need code for two buttons. to save the tab delimited file in the file. and when i press the 2nd button to italisize the # delimited text in the file.
thank u,
thiru
|
|
|
|
|
Ok. There is nothing "tab delimited" about your initial post.
All your doing is saving the Text to a file. If your using a RichTextBox control, all you need is the .LoadFile and .SaveFile methods to do this for you.
The the second part, you have to scan the text to find the first occurance of a '#' character. Save that position. Continue scanning until you find the next '#". This will give you enough information to set the .SelectStart and .SelectLegth properties of the RichTextBox, then use the .SelectionFont property to change the font to italics. An example of which is found here[^] on MSDN.
Why does this smell like homework?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Is there a way, to get at the 'Main Bindable Property' of any given control. I am thinking, probably using system.reflection but i don't know how.
I have a bunch of different controls and i need to programmatically bind them to a dataset. To create a windows.forms.binder i need to know the property i want to bind to - the main bindable property for this particular control.
Help anyone?
Jan Engel Ketmig
|
|
|
|
|
JanEngelKetmig wrote:
'Main Bindable Property'
?????
Are you talking about the "default property"? Like Text for a TextBox?
I think you're looking for DefaultPropertyAttribute[^], which you should be able to find using Reflection. I don't have any example code, because frankly, I've never had to find/use the DefaultProperty for anything.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
WOW that was fast... yes!, that oughtta do it... Thanks man..!
Jan Engel Ketmig
|
|
|
|
|
Hello there
I have one folder on C drive and I want to move it to any other logical drive D or E. I am using this code which gives me error that cannot move between logical drives.
Note: The Source Folder could have N Number of sub folders and files
System.IO.Directory.Move("C:\TestFolder", "D:\TestFolder")
I also tried this which gives me error that file not found....
Rename("C:\TestFolder", "D:\TestFolder")
Any Solution will be appreciated
Best Regards
Rizwan Bashir
|
|
|
|
|
Uhhhh.... The error message should make it obvious. You can't move between two drives/volumes/shares. You can, however, copy the source to the destination, then go back and delete the source. You can only move when the source and destination are on the same drive/volume/share.
This is spelled out in the documentation for Directory.Move , here[^] on MSDN. Look under Exceptions.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i work on database application with vb6
and i depend on data control in my program
from other side, i build my databse file with data manager
on vb6?
how can i protect .mdb file with password?
and how can i open it from vb6 in this case?
|
|
|
|
|
You can protect your Access database with a password all you want. But it can be broken and revealed so easily with off-the-shelf utlities that anyone can download from the web for FREE. Why waste your time?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
what are others stratigies about security?
|
|
|
|
|
In an Access database? There are none. Access is meant as a desktop database, not a secure storage medium. The only other you can do is encrypt the sensitive data before it's sent to the datbase, but you won't be able to search on it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Hi All
I want to buy a DHTML Edit control, which i can use in my VB.NET Windows Applivation. I dont want to use control provided by .NET itself. Can anybody please suggest me a nice control control for the same purpose.
Thanks
Sumit Domyan
|
|
|
|
|
Hi there! Can anyone help me with this: what dll's do i need in order to export a crystal report to text format during runtime.
When i run my program in visual basic 6, the exporting is done successfully. but when im using it in .exe, errors are generated.
i already used U2FTXT.DLL
what could be the problem?
pls help me.... thanks a lot!
|
|
|
|
|
I have a combo box on a windows form i'm using (in vstudio .NET 2003). It has to be a combo box, and I don't want the combobox to display the same text as what the selected value is. for example, i have four items in it now. when it drops down the user sees:
item 1
item 2
item 3
item 4
when the user clicks on item 1, instead of the box collapsing and displaying "item 1", i want it to display "this is a test". how do i do this? I've already tried comboBox3.Text = "this is a test" and putting it in the selectedIndexChanged, selectedValueChanged, Click, mouseUp, and textChanged events for the combobox, but it doesn't work. it still displays whatever i clicked. what's going wrong?
|
|
|
|
|
Hi,
If it may help you and i really understood what you mean, I think may be you need a Lable near your comboBox. Whenever a user clicks on one of the Items in cmb then your Lable will tell
i hate combo boxes wrote:
this is a test
I hope it helps.
Good Luck
Acheto
|
|
|
|
|
you will have to manually draw the ComboBox Items. Set the OwnerDraw property to OwnerDrawFixed then have a look at the ComboBox.DrawItem event.
Let me know if you need more help on this.
Cheers
Tom
|
|
|
|
|
well actually the combo box is already an owner drawn one. This is the problem, in my combo box, i set it to owner drawn so the first line of my combo box was bold and underlined - acting as a header. So basically since this first line is acting as a header I don't want the user to be able to select/display that value when they click on it. I had looked in to somehow disabling that first item, but no luck. so i figured i'd cheat and just change the text when they click on it to make it seem that it was disabled. here's my code for the box:
Friend WithEvents ComboBox3 As System.Windows.Forms.ComboBox<br />
Private selectControls() As String<br />
<br />
<br />
Private Sub initializeComboBox()<br />
Me.ComboBox3 = New ComboBox<br />
Me.ComboBox3.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed<br />
Me.ComboBox3.Location = New System.Drawing.Point(10, 20)<br />
Me.ComboBox3.Name = "ComboBox3"<br />
Me.ComboBox3.Size = New System.Drawing.Size(136, 21)<br />
Me.ComboBox3.DropDownWidth = 136<br />
Me.ComboBox3.TabIndex = 0<br />
Me.ComboBox3.DropDownStyle = ComboBoxStyle.DropDown<br />
Me.ComboBox3.Location = New System.Drawing.Point(120, 112)<br />
selectControls = New String() {"Serial Status", "10303 test", "bloop!"}<br />
ComboBox3.DataSource = selectControls<br />
Me.Controls.Add(Me.ComboBox3)<br />
End Sub<br />
<br />
Protected Sub ComboBox3_DrawItem(ByVal sender As Object, _<br />
ByVal e As System.Windows.Forms.DrawItemEventArgs) _<br />
Handles ComboBox3.DrawItem<br />
<br />
Dim size As Single<br />
Dim myFont As System.Drawing.Font<br />
Dim family As FontFamily<br />
<br />
Dim itemColor As New System.Drawing.Color<br />
Select Case e.Index<br />
Case 0<br />
size = 8.25<br />
<br />
itemColor = System.Drawing.Color.White<br />
family = FontFamily.GenericSansSerif<br />
myFont = New Font(family, size, FontStyle.Bold Or FontStyle.Underline)<br />
<br />
Case 1<br />
size = 8.25<br />
itemColor = System.Drawing.Color.White<br />
family = FontFamily.GenericSansSerif<br />
myFont = New Font(family, size, FontStyle.Regular)<br />
Case 2<br />
size = 8.25<br />
itemColor = System.Drawing.Color.Blue<br />
family = FontFamily.GenericSansSerif<br />
myFont = New Font(family, size, FontStyle.Regular)<br />
<br />
End Select<br />
<br />
e.DrawBackground()<br />
<br />
Dim rect = New Rectangle(1, 0, 134, 15)<br />
e.Graphics.FillRectangle(New SolidBrush(Color.Empty), _<br />
rect)<br />
<br />
If e.State = 769 Then<br />
<br />
If e.Index = 0 Then <br />
<br />
e.Graphics.FillRectangle(New SolidBrush(Color.White), _<br />
rect)<br />
<br />
e.Graphics.DrawString(selectControls(e.Index), myFont, System.Drawing.Brushes.Black, _<br />
New System.Drawing.PointF(2, e.Bounds.Top))<br />
<br />
Else<br />
<br />
e.Graphics.DrawString(selectControls(e.Index), myFont, System.Drawing.Brushes.White, _<br />
New System.Drawing.PointF(2, e.Bounds.Top))<br />
End If<br />
<br />
Else<br />
<br />
e.Graphics.DrawString(selectControls(e.Index), myFont, System.Drawing.Brushes.Black, _<br />
New System.Drawing.PointF(2, e.Bounds.Top))<br />
<br />
<br />
End If<br />
e.DrawFocusRectangle()<br />
<br />
End Sub
I'm not too familiar with owner drawn stuff, I can do little stuff like this but real complex stuff i haven't had experience with yet. is there any way to tell it in here to display a different value for the item when it's clicked?
|
|
|
|
|
I am trying to create an autocomplete combobox for a datagrid in vb.net.
I have everything working, except that I cannot force the column to stop when a user presses TAB to enter the column.
I need to allow the user to press tab, and then my datagridcolumn must gain focus, but I cannot figure out how
Anyways, I've attached my code (It's based on some previous articles I have read).
I can get the control to retain focus when TAB is pressed if I put a break-point in the OnEnter(ByVal e as System.EventArgs)
of the NoKeyUpCombo Class, but not without that.
Please help!!!!
Jake
DataGridComboBoxColumn:
<br />
Option Strict Off<br />
Option Explicit On <br />
<br />
Imports Microsoft.VisualBasic<br />
Imports System<br />
Imports System.ComponentModel<br />
Imports System.Data<br />
Imports System.Data.Common<br />
Imports System.Data.OleDb<br />
Imports System.Drawing<br />
Imports System.Windows.Forms<br />
<br />
Namespace DataGridTextBoxCombo<br />
' Step 1. Derive a custom column style from DataGridTextBoxColumn<br />
' a) add a ComboBox member<br />
' b) track when the combobox has focus in Enter and Leave events<br />
' c) override Edit to allow the ComboBox to replace the TextBox<br />
' d) override Commit to save the changed data<br />
Public Class DataGridComboBoxColumn<br />
Inherits DataGridTextBoxColumn<br />
Public WithEvents ColumnComboBox As NoKeyUpCombo<br />
Private _source As System.Windows.Forms.CurrencyManager<br />
Private _rowNum As Integer<br />
Private _isEditing As Boolean<br />
Public Shared _RowCount As Integer<br />
<br />
<br />
Public Sub New()<br />
_source = Nothing<br />
_isEditing = False<br />
_RowCount = -1<br />
<br />
ColumnComboBox = New NoKeyUpCombo<br />
ColumnComboBox.DropDownStyle = ComboBoxStyle.DropDown<br />
<br />
AddHandler ColumnComboBox.SelectionChangeCommitted, AddressOf ComboStartEditing<br />
End Sub 'New<br />
<br />
Private Sub HandleScroll(ByVal sender As Object, ByVal e As EventArgs)<br />
If ColumnComboBox.Visible Then<br />
ColumnComboBox.Hide()<br />
End If<br />
End Sub 'HandleScroll<br />
<br />
Private Sub ComboStartEditing(ByVal sender As Object, ByVal e As EventArgs)<br />
_isEditing = True<br />
MyBase.ColumnStartedEditing(sender)<br />
End Sub 'ComboMadeCurrent<br />
<br />
<br />
Private Sub CompletionCombo_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles ColumnComboBox.Leave<br />
If _isEditing Or ColumnComboBox._isEditing Then<br />
SetColumnValueAtRow(_source, _rowNum, ColumnComboBox.Text)<br />
_isEditing = False<br />
Invalidate()<br />
<br />
End If<br />
ColumnComboBox.Hide()<br />
AddHandler Me.DataGridTableStyle.DataGrid.Scroll, New EventHandler(AddressOf HandleScroll)<br />
End Sub 'LeaveComboBox<br />
<br />
<br />
Protected Overloads Overrides Sub Edit(ByVal [source] As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal bounds As System.Drawing.Rectangle, ByVal [readOnly] As Boolean, ByVal instantText As String, ByVal cellIsVisible As Boolean)<br />
<br />
MyBase.Edit([source], rowNum, bounds, [readOnly], instantText, cellIsVisible)<br />
<br />
'_isEditing = True<br />
_rowNum = rowNum<br />
_source = [source]<br />
<br />
ColumnComboBox.Parent = Me.TextBox.Parent<br />
ColumnComboBox.Location = Me.TextBox.Location<br />
ColumnComboBox.Size = New Size(Me.TextBox.Size.Width, ColumnComboBox.Size.Height)<br />
'ColumnComboBox.SelectedIndex = ColumnComboBox.FindStringExact(Me.TextBox.Text)<br />
ColumnComboBox.Text = Me.TextBox.Text<br />
Me.TextBox.Visible = False<br />
ColumnComboBox.Visible = True<br />
AddHandler Me.DataGridTableStyle.DataGrid.Scroll, AddressOf HandleScroll<br />
<br />
ColumnComboBox.BringToFront()<br />
ColumnComboBox.Focus()<br />
End Sub 'Edit<br />
<br />
<br />
Protected Overrides Function Commit(ByVal dataSource As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer) As Boolean<br />
<br />
If _isEditing Then<br />
_isEditing = False<br />
SetColumnValueAtRow(dataSource, rowNum, ColumnComboBox.Text)<br />
End If<br />
Return True<br />
End Function 'Commit<br />
<br />
<br />
Protected Overrides Sub ConcedeFocus()<br />
Console.WriteLine("ConcedeFocus")<br />
MyBase.ConcedeFocus()<br />
End Sub 'ConcedeFocus<br />
<br />
Protected Overrides Function GetColumnValueAtRow(ByVal [source] As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer) As Object<br />
<br />
Dim s As Object = MyBase.GetColumnValueAtRow([source], rowNum)<br />
Dim dv As DataView = CType(Me.ColumnComboBox.DataSource, DataView)<br />
Dim rowCount As Integer = dv.Count<br />
Dim i As Integer = 0<br />
Dim s1 As Object<br />
<br />
'if things are slow, you could order your dataview<br />
'& use binary search instead of this linear one<br />
While i < rowCount<br />
s1 = dv(i)(Me.ColumnComboBox.ValueMember)<br />
If (Not s1 Is DBNull.Value) AndAlso _<br />
(Not s Is DBNull.Value) AndAlso _<br />
s = s1 Then<br />
Exit While<br />
End If<br />
i = i + 1<br />
End While<br />
<br />
If i < rowCount Then<br />
Return dv(i)(Me.ColumnComboBox.DisplayMember)<br />
End If<br />
Return DBNull.Value<br />
End Function 'GetColumnValueAtRow<br />
<br />
<br />
Protected Overrides Sub SetColumnValueAtRow(ByVal [source] As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal value As Object)<br />
Dim s As Object = value<br />
<br />
Dim dv As DataView = CType(Me.ColumnComboBox.DataSource, DataView)<br />
Dim rowCount As Integer = dv.Count<br />
Dim i As Integer = 0<br />
Dim s1 As Object<br />
<br />
'if things are slow, you could order your dataview<br />
'& use binary search instead of this linear one<br />
While i < rowCount<br />
s1 = dv(i)(Me.ColumnComboBox.DisplayMember)<br />
If (Not s1 Is DBNull.Value) AndAlso _<br />
s = s1 Then<br />
Exit While<br />
End If<br />
i = i + 1<br />
End While<br />
If i < rowCount Then<br />
s = dv(i)(Me.ColumnComboBox.ValueMember)<br />
Else<br />
s = DBNull.Value<br />
End If<br />
MyBase.SetColumnValueAtRow([source], rowNum, s)<br />
End Sub 'SetColumnValueAtRow <br />
<br />
End Class 'DataGridComboBoxColumn<br />
<br />
<br />
End Namespace<br />
NoKeyUpCombo.vb:
<br />
Option Strict Off<br />
Option Explicit On <br />
<br />
Imports Microsoft.VisualBasic<br />
Imports System<br />
Imports System.ComponentModel<br />
Imports System.Data<br />
Imports System.Data.Common<br />
Imports System.Data.OleDb<br />
Imports System.Drawing<br />
Imports System.Windows.Forms<br />
<br />
Namespace DataGridTextBoxCombo<br />
Public Class NoKeyUpCombo<br />
Inherits ComboBox<br />
Private WM_KEYUP As Integer = &H101<br />
Public _isEditing As Boolean = False<br />
<br />
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)<br />
If m.Msg = WM_KEYUP Then<br />
'ignore keyup to avoid problem with tabbing & dropdownlist;<br />
Return<br />
End If<br />
MyBase.WndProc(m)<br />
End Sub 'WndProc<br />
<br />
Protected Overrides Sub OnEnter(ByVal e As System.EventArgs)<br />
_isEditing = True<br />
MyBase.Focus()<br />
End Sub<br />
<br />
Private Sub CompletionCombo_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp<br />
Dim sTypedText As String<br />
Dim iFoundIndex As Integer<br />
Dim oFoundItem As Object<br />
Dim sFoundText As String<br />
Dim sAppendText As String<br />
<br />
If Me.Items.Count > 0 Then<br />
'Allow select keys without Autocompleting<br />
Select Case e.KeyCode<br />
Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, Keys.Delete, Keys.Down, Keys.ControlKey, Keys.ShiftKey, Keys.Alt, Keys.ShiftKey, Keys.MButton, Keys.LButton, Keys.RButton, Keys.Home, Keys.End<br />
'e.Handled = False<br />
Exit Sub<br />
End Select<br />
<br />
'Get the Typed Text and Find it in the list<br />
If Me.Text.Length > 0 And Me.Text.Length <> Me.SelectedText.Length Then<br />
sTypedText = Me.Text<br />
iFoundIndex = Me.FindString(sTypedText)<br />
<br />
'If we found the Typed Text in the list then Autocomplete<br />
If iFoundIndex >= 0 Then<br />
'Get the Item from the list (Return Type depends if Datasource was bound <br />
' or List Created)<br />
oFoundItem = Me.Items(iFoundIndex)<br />
<br />
'Use the ListControl.GetItemText to resolve the Name in case the Combo <br />
' was Data bound<br />
sFoundText = Me.GetItemText(oFoundItem)<br />
<br />
'Append then found text to the typed text to preserve case<br />
sAppendText = sFoundText.Substring(sTypedText.Length)<br />
Me.Text = sTypedText & sAppendText<br />
<br />
'Select the Appended Text<br />
Me.SelectionStart = sTypedText.Length<br />
Me.SelectionLength = sAppendText.Length<br />
'Me.SelectedIndex = iFoundIndex<br />
End If<br />
End If<br />
End If<br />
<br />
End Sub<br />
<br />
Private Sub CompletionCombo_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Leave<br />
Dim iFoundIndex As Integer<br />
<br />
If Me.Items.Count > 0 Then<br />
Dim sFoundText As String = ""<br />
If Me.SelectedText.Length <> Me.Text.Length Then<br />
sFoundText = Me.Text.Substring(Me.SelectedText.Length, Me.Text.Length)<br />
End If<br />
If sFoundText.Length > 0 Then<br />
iFoundIndex = Me.FindString(Me.Text)<br />
<br />
Me.SelectedIndex = iFoundIndex<br />
End If<br />
End If<br />
<br />
' Now ask to make a new address, if there is no autocomplete.<br />
If MyBase.SelectedIndex = -1 And MyBase.Text.Length > 0 Then<br />
If MessageBox.Show("Cannot find item: '" & MyBase.Text & "'." & vbCrLf & "Would you like to create a new item?", "Create a New Entry?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then<br />
' TODO: Add code to make a new inventory item.<br />
Else<br />
MyBase.Text = ""<br />
MyBase.Focus()<br />
End If<br />
End If<br />
End Sub<br />
End Class 'NoKeyUpCombo<br />
End Namespace<br />
<br />
|
|
|
|
|