|
Thanks, that is exactly what I was attempting to accomplish. I will also follow the advice on properties as well.
|
|
|
|
|
What if you wanted to pass the struct as a parameter to method in a different object? Would a struct be the best solution, or is there a better way to that?
|
|
|
|
|
Depends on what your struct contains. If you want value semantics, that is, if you want to pass around a copy of your data everywhere, you can use a struct, otherwise, you can use a class. This[^] might help you decide which one to use.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
My project will be accessing production data off of a *nix box via samba. When the data path is pointing to a local test dataset, or a test set on a remote windows machine everything works fine. But when I change the path to point at a folder on a linuxbox made accessable via samba the application doesn't update.
|
|
|
|
|
From Googling around on this subject, it appears that there are major problems with getting this to work. It doesn't look like there is a great amount of support. About the only thing I could suggest is upgrading the Samba server to the latest and see what happens.
http://www.samba.org[^]
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote: From Googling around on this subject, it appears that there are major problems with getting this to work. It doesn't look like there is a great amount of support. About the only thing I could suggest is upgrading the Samba server to the latest and see what happens.
Bleh. Easier said than done on the client end unfortunately.
|
|
|
|
|
Hello everyone,
I'm trying to 'log' Terminal Server activity. From a fileserver I want to access the Security-logs from the Terminal Server. In those logs we can retrieve log-in and log-out date and times including username.
Offcourse, I did some research... but after a couple of hours i gave up... can't find anything usefull.
<br />
<br />
EventLog elog = new EventLog("test","172.16.2.18");<br />
elog.Log = "Security";<br />
<br />
string one = elog.Entries[i].MachineName;<br />
string two = elog.Entries[i].index;<br />
string etc. etc.<br />
<br />
During my search for the truth out there I came across these classes:
System.Security.Permissions.RegistryPermission
..and..
System.Security.Permissions.SecurityPermission
only I don't know how to apply these classes. Can anyone give me a codesnippet/example?
Thnx in advance!
|
|
|
|
|
i write a Numeric column class Set. But whenever i try to enter any value to numeric cell i got error and application restards itself. Exception is "TargetinvocationException ; Exception has been thrown by the target of an invocation."
NOTE : I create a table at run time, then i bind it to DataGridView. Table has one row at first.
CODE: : : : : :
Imports System<br />
Imports System.Windows.Forms<br />
<br />
#Region "NumericColumn Class"<br />
Public Class NumericColumn<br />
Inherits DataGridViewColumn<br />
<br />
Public Sub New()<br />
MyBase.New(New NumericCell())<br />
End Sub 'New<br />
<br />
<br />
Public Overrides Property CellTemplate() As DataGridViewCell<br />
Get<br />
Return MyBase.CellTemplate<br />
End Get<br />
Set(ByVal value As DataGridViewCell)<br />
' Ensure that the cell used for the template is a NumericCell<br />
If Not (value Is Nothing) And Not value.GetType().IsAssignableFrom(GetType(NumericCell)) Then<br />
Throw New InvalidCastException("Must be a NumericCell")<br />
End If<br />
MyBase.CellTemplate = value<br />
End Set<br />
End Property<br />
End Class<br />
#End Region<br />
<br />
#Region "NumericCell Class"<br />
Public Class NumericCell<br />
Inherits DataGridViewTextBoxCell<br />
<br />
<br />
Public Sub New()<br />
<br />
End Sub<br />
<br />
<br />
Public Overrides Sub InitializeEditingControl(ByVal rowIndex As Integer, ByVal initialFormattedValue As Object, ByVal dataGridViewCellStyle As DataGridViewCellStyle)<br />
MyBase.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle)<br />
Dim ctl As NumericEditingControl = CType(DataGridView.EditingControl, NumericEditingControl)<br />
ctl.Text = Commas.SetComma(Me.Value)<br />
End Sub<br />
<br />
<br />
Public Overrides ReadOnly Property EditType() As Type<br />
Get<br />
' Return the type of the editing contol that NumericCell uses.<br />
Return GetType(NumericEditingControl)<br />
End Get<br />
End Property<br />
<br />
<br />
Public Overrides ReadOnly Property ValueType() As Type<br />
Get<br />
' Return the type of the value that NumericCell contains.<br />
Return GetType(String)<br />
End Get<br />
End Property<br />
<br />
<br />
Public Overrides ReadOnly Property DefaultNewRowValue() As Object<br />
Get<br />
' Use the current date and time as the default value.<br />
Return "0.00"<br />
End Get<br />
End Property<br />
End Class<br />
#End Region<br />
<br />
#Region "NumericEditingControl Class"<br />
Class NumericEditingControl<br />
Inherits System.Windows.Forms.TextBox<br />
Implements IDataGridViewEditingControl<br />
<br />
Private dataGridViewControl As DataGridView<br />
Private TextIsChanged As Boolean = False<br />
Private rowIndexNum As Integer<br />
<br />
<br />
Public Sub New()<br />
Me.Text = "0.00"<br />
End Sub 'New<br />
<br />
' Implements the IDataGridViewEditingControl.EditingControlFormattedValue property.<br />
Public Property EditingControlFormattedValue() As Object Implements IDataGridViewEditingControl.EditingControlFormattedValue<br />
Get<br />
Return Me.Text<br />
End Get<br />
Set(ByVal value As Object)<br />
'If TypeOf value Is [String] Then<br />
Me.Text = Commas.SetComma(value) 'DateTime.Parse(CStr(value))<br />
'End If<br />
End Set<br />
End Property<br />
<br />
<br />
' Implements the IDataGridViewEditingControl.GetEditingControlFormattedValue method.<br />
Public Function GetEditingControlFormattedValue(ByVal context As DataGridViewDataErrorContexts) As Object Implements IDataGridViewEditingControl.GetEditingControlFormattedValue<br />
Return Me.Text<br />
End Function 'GetFormattedValue<br />
<br />
<br />
' Implements the IDataGridViewEditingControl.ApplyCellStyleToEditingControl method.<br />
Public Sub ApplyCellStyleToEditingControl(ByVal dataGridViewCellStyle As DataGridViewCellStyle) Implements IDataGridViewEditingControl.ApplyCellStyleToEditingControl<br />
Me.Font = dataGridViewCellStyle.Font<br />
'Me.NumericForeColor = dataGridViewCellStyle.ForeColor<br />
'Me.NumericMonthBackground = dataGridViewCellStyle.BackColor<br />
End Sub 'UseCellStyle<br />
<br />
' Implements the IDataGridViewEditingControl.EditingControlRowIndex property.<br />
Public Property EditingControlRowIndex() As Integer Implements IDataGridViewEditingControl.EditingControlRowIndex<br />
Get<br />
Return rowIndexNum<br />
End Get<br />
Set(ByVal value As Integer)<br />
rowIndexNum = value<br />
End Set<br />
End Property<br />
<br />
<br />
' Implements the IDataGridViewEditingControl.EditingControlWantsInputKey method.<br />
Public Function EditingControlWantsInputKey(ByVal key As Keys, ByVal dataGridViewWantsInputKey As Boolean) As Boolean Implements IDataGridViewEditingControl.EditingControlWantsInputKey<br />
<br />
' Let the DateTimePicker handle the keys listed.<br />
Select Case key And Keys.KeyCode<br />
Case Keys.Left, Keys.Up, Keys.Down, Keys.Right, Keys.Home, Keys.End, Keys.PageDown, Keys.PageUp<br />
Return True<br />
Case Else<br />
Return False<br />
End Select<br />
End Function 'IsInputKey<br />
<br />
<br />
' Implements the IDataGridViewEditingControl.PrepareEditingControlForEdit method.<br />
Public Sub PrepareEditingControlForEdit(ByVal selectAll As Boolean) Implements IDataGridViewEditingControl.PrepareEditingControlForEdit<br />
' No preparation needs to be done.<br />
End Sub 'PrepareForEdit<br />
<br />
' Implements the IDataGridViewEditingControl.RepositionEditingControlOnValueChange<br />
' property.<br />
Public ReadOnly Property RepositionEditingControlOnValueChange() As Boolean Implements IDataGridViewEditingControl.RepositionEditingControlOnValueChange<br />
Get<br />
Return False<br />
End Get<br />
End Property<br />
<br />
' Implements the IDataGridViewEditingControl.EditingControlDataGridView property.<br />
Public Property EditingControlDataGridView() As DataGridView Implements IDataGridViewEditingControl.EditingControlDataGridView<br />
Get<br />
Return dataGridViewControl<br />
End Get<br />
Set(ByVal value As DataGridView)<br />
dataGridViewControl = value<br />
End Set<br />
End Property<br />
<br />
' Implements the IDataGridViewEditingControl.EditingControlValueChanged property.<br />
Public Property EditingControlValueChanged() As Boolean Implements IDataGridViewEditingControl.EditingControlValueChanged<br />
Get<br />
Return TextIsChanged<br />
End Get<br />
Set(ByVal value As Boolean)<br />
TextIsChanged = value<br />
End Set<br />
End Property<br />
<br />
' Implements the IDataGridViewEditingControl.EditingPanelCursor method.<br />
Public ReadOnly Property EditingPanelCursor() As Cursor Implements IDataGridViewEditingControl.EditingPanelCursor<br />
Get<br />
Return MyBase.Cursor<br />
End Get<br />
End Property<br />
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)<br />
MyBase.OnTextChanged(e)<br />
TextIsChanged = True<br />
Me.EditingControlDataGridView.NotifyCurrentCellDirty(True)<br />
End Sub<br />
Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)<br />
Dim asciiInteger As Integer = Asc(e.KeyChar)<br />
Select Case asciiInteger<br />
Case 48 To 57 'Number<br />
e.Handled = False<br />
Case 8 'Backspace<br />
e.Handled = False<br />
Case 46 'Point<br />
If Not Text.Length = 0 Then<br />
If Not Text.Contains(".") Then<br />
e.Handled = False<br />
Else<br />
e.Handled = True<br />
End If<br />
Else<br />
e.Handled = True<br />
End If<br />
Case Else 'Yanlış Giriş<br />
e.Handled = True<br />
End Select<br />
End Sub<br />
<br />
End Class 'NumericEditingControl<br />
#End Region<br />
<br />
<br />
<br />
|
|
|
|
|
Hey
I want to print a menu out of a listview.
I am using drawing lines using drawline method, but I am using a string[] to get the text being printed (using drawstring), the thing is that I do not know how to tell the string to start and ending printing inside a defined border. I mean, how do I give the string a maximum pixel and a minimum pixel to create a border?
thanks!
|
|
|
|
|
Hey
I want to print a menu out of a listview.
I am using drawing lines using drawline method, but I am using a string[] to get the text being printed (using drawstring), the thing is that I do not know how to tell the string to start and ending printing inside a defined border. I mean, how do I give the string a maximum pixel and a minimum pixel to create a border?
thanks!
|
|
|
|
|
does No one know how to override datagridview columns, I found an example but i couldnt download, or got any clue :S
this
|
|
|
|
|
I need to read Nt event logger if specific error exists in the logger I need to get the description and store it in log.
How can I do this please help.
|
|
|
|
|
|
Hi There Friend,
I am confused with ListView Control. I Want to Do Highlight and UN-HighLight
a ListViewItem in listview manually but setting neither Selected nor Focused property of any ListViewItem makes it HighLight(But it is being selected).Can U tell me How can I Do this that feel just like a mouse selection without clicking?(Please Do not offer BackColor or ForeColor !!!)
Ali Beirami
Ali Beirami
|
|
|
|
|
I looking for a way to signal a function in a running thread to stop what is doing, clean up, and then end. The thread runs testing code that I don't have control over. Since I don't have access to this section of code there is no way for me to put checks in for a flag to end a test run. I check a flag just before a function runs the unknown code and just after to stop the thread, this works. But some of the unknown code can run for hours and I need a way to throw an exception, signal, or interrupt the function that executes this code in the thread. The interrupt would be coming from the program that started this testing thread.
// This runs an individual test.
method.Invoke( test, null ); <<-- This is where I need to get into.
Thanks
Mark
-- modified at 8:15 Thursday 20th October, 2005
|
|
|
|
|
Unless a thread is designed to be interupted or killed from any location, it is generally a bad idea to stop a thread of execution from the outside. You can easily leave whatever the thread is touching in a bad state by just killing the thread wherever. For instance if you are writing data to media you could be in the middle of the file when you externally tell the thread to end leaving you with junk data.
I would first look to see if there is a way to redo your application in such a way to avoid having the need to kill threads. But if you really really really want to halt a thread, use Abort which will generate a ThreadAbortException .
Hint: you will still need to Join even after you use Abort .
|
|
|
|
|
Is there a way I can?
1. Throw an exception to the thread. So I catch that exception within the thread.
2. Or catch the ThreadAbortException in the thread.
Thanks
|
|
|
|
|
RochesterMark wrote: Throw an exception to the thread. So I catch that exception within the thread.
While you can't inject arbitrary exceptions into the thread code, if you know the code that the thread is executing, you can make those methods throw exceptions. Not an elegant solution.
RochesterMark wrote: Or catch the ThreadAbortException in the thread.
You can't. That would break the whole purpose of ThreadAbortException, won't it? What if you just catch it and proceed like nothing happened?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Basically yeah what Senthil wrote.
RochesterMark wrote: 1. Throw an exception to the thread. So I catch that exception within the thread.
No. Threads by definition hold their own stack. Any reference, including exceptions, generated in one thread are meaningless in another. Trying to mess with another stack frame is of dubious value no mater what you are trying.
What you are thinking about is a concept like a "signal" or events or other cross threading data ideas (ala. IPC, shared memory segments, etc). I avoided mentioning these things because they are really somewhat advanced.
RochesterMark wrote: 2. Or catch the ThreadAbortException in the thread.
Once again, exception generated in one thread is meaningless in another. Trying to catch an exception that isn't in your stack frame is a weird concept anyway. Throwing an exception modifies the stack of the current context. Catching the exception of another thread is as "crazy" as making another thread call a function in the middle of execution.
It is my experience that most of the time when someone is asking a question that violates fundemental principals of a system, in this case Threading, they need to seriously reevaluate what is going on. Trying to force a thread to actively manipulate the stack of another thread is simply not sane even if the runtime allowed it so why would a software engineer want to write software that does this?
|
|
|
|
|
i want some code exercises because i haven't been programming for 3months know !!!where can i get them??????????????????//
|
|
|
|
|
just go through some exercises of walk through in MSDN
and u then can wrap up some articles to post here .... ;(
<< >>
|
|
|
|
|
|
Just read the questions in this forum and code up answers. :->
Matt Gerrans
|
|
|
|
|
True enough. thats how i started learning
Aim small, miss small...
|
|
|
|
|
hi all !
How to check all records in all pages across grid with a single click..and those check boxes has to maintain the state in paging of grid..
kris
|
|
|
|