|
|
Mika,
I understand that it would translate to :
IF e.state & drawitemstate.focus = 0 then
checkboxstate = checkednormal
else
checkboxstate = uncheckednormal
but I need to pass in the checked state as a parameter and it is expecting a statement where I cannot have an IF statement.
Thanks
|
|
|
|
|
I don't quite follow. I would have believed that e was referring to event arguments passed to an event handler and that State would have been a property for the argument instance.
Or is the problem that in C# & is AND operator and if I remember correctly, in VB & means concatenation?
|
|
|
|
|
Mika,
The whole statement in C# is like this:
CheckBoxRenderer.DrawCheckBox(
e.Graphics,
new Point( e.Bounds.X, e.Bounds.Y ),
e.Bounds,
box.Text,
this.Font,
( e.State & DrawItemState.Focus ) == 0,
box.CheckState ? CheckBoxState.CheckedNormal :
CheckBoxState.UncheckedNormal )
Thanks
|
|
|
|
|
|
ByVal e As DrawItemEventArgs
|
|
|
|
|
Okay, break the statement into pieces:
- define a variable of type VisualStyles.CheckBoxState
- assign a value to it using If block
- pass the variable to CheckBoxRenderer.DrawCheckBox method as state parameter
|
|
|
|
|
Running this through http://codeconverter.sharpdevelop.net/SnippetConverter.aspx[^] produces:
CheckBoxRenderer.DrawCheckBox(e.Graphics, _
New Point(e.Bounds.X, e.Bounds.Y), _
e.Bounds, box.Text, Me.Font, _
(e.State And DrawItemState.Focus) = 0, _
If(box.CheckState, CheckBoxState.CheckedNormal, CheckBoxState.UncheckedNormal))
The usage of "If" inside expressions is new in VB9 (VS08), for older versions, use IIf or split it into two statements.
|
|
|
|
|
Have you tried looking at code converters through a google search? SharpDevelop had a good one a while back, you may want to look at it.
http://codeconverter.sharpdevelop.net/[^] is the one I used before. It is helpful
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I have wrote below code for creating Text file and then after storing line by line value in Text File.
If Not System.IO.File.Exists(strFileName) Then
Dim fs As FileStream = File.Create(strFileName)
fs.Flush()
fs.Close()
End If
Dim ObjFile As StreamWriter
ObjFile = File.AppendText(strFileName)
ObjFile.WriteLine(Now() & "---" & strStatus & "---"&strErrMsg)
ObjFile.Flush()
ObjFile.Close()
My problem is while i am running my autoprocess in server it gives me error like "The process cannot access the file XYZ.txt because it is being used by another process"
What is wrong in this code as i had close file as well object also.
Thanks.
|
|
|
|
|
First, you can comment out the file creation since it is created if it doesn't exists. After that do you still have the problem?
Mika
|
|
|
|
|
I did not get you but i had change by code with below lines
SWObj = New StreamWriter(strFile, True)
SWObj.WriteLine(rno )
SWObj.Flush()
SWObj.Close()
And i commented lines which creating File.
Thanks
|
|
|
|
|
What I meant is that the documentation for AppendText says:
Remarks: This method is equivalent to the StreamWriter(String, Boolean) constructor overload. If the file specified by path does not exist, it is created. If the file does exist, write operations to the StreamWriter append text to the file
So you don't need to create the file. The following code is enough:
Dim ObjFile As StreamWriter
ObjFile = File.AppendText(strFileName) <------- File is created if necessary
ObjFile.WriteLine(Now() & "---" & strStatus & "---"&strErrMsg)
ObjFile.Flush()
ObjFile.Close()
Did this get the problem solved?
Mika
|
|
|
|
|
Yea, Thanks you so much...Appreciate you help..
|
|
|
|
|
|
Hello Experts!!
I am creating 2 datasets after retreiving infromation from excel sheet, now i want to store these datasets in a sql database.
any ideas how to get this done?
Thanks in Advance!!
|
|
|
|
|
Anything you tried??
"If you had to identify, in one word, the reason why the human race has not achieved, and never will achieve, its full potential, that word would be 'meetings'." - Dave Barry
|
|
|
|
|
I tried sqlbulkcopy and doesnt look good for me...
|
|
|
|
|
|
I will try this in the morning tomorrow and let you know,
can you type in 2 lines of code showing it with SqlDataAdapter?
I am not sure of the properties of it.
Thanks Mika!
|
|
|
|
|
|
|
Arrays are just like any other variable. If you want to preserve the value of an array between method calls, put the array declaration outside the method.
If by "different process" you mean different thread, that is more challenging. Not my field of expertise, but the technique should be the same as sharing any variables.
|
|
|
|
|
This thing has been kicking my a$# for 2 days.
All I wanted to do was iterate through a dataset and pick to columns of data to make an array to pass to plot some points on a graph, draw the graph and the plotted lines.
All works well but I can not figure out how to get the array of the data to the drawing sub....
Driving me crazy...
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Ah, so your question is, "I have an array; how do I pass it as a parameter?" Declare your drawing subroutine like this:
Private Sub PlotPoints(ByVal Points As Double())
(Code goes here)
End Sub You will notice the opening and closing parentheses after the As Double part. That tells the compiler to expect an array of Double (or whatever type) rather than a single value.
If you have a complex data type -- your point data is in the form of (x coordinate, y coordinate) -- you might find it easier to create a class, then generate and pass a list:
Public Class MyPoint
Public XCoord As Double
Public YCoord As Double
End Class
Private Sub PlotPoints(ByVal Points As List(Of MyPoint))
End Sub I've been doing .Net for so long at this point that I tend to prefer lists over arrays.
|
|
|
|