|
Hello !
I have implemented Imessage filter to resolve my case.
This is the class :
Imports System.Windows.Forms
Public Delegate Sub InsideDelegate(ByRef value As Boolean)
Public Class MyMessageFilter
Implements IMessageFilter
Public Event Inside As InsideDelegate
Private Const WM_LBUTTONDOWN As Integer = &H201
Private Const WM_LBUTTONUP As Integer = &H202
Public Function PreFilterMessage(ByRef m As Message) As Boolean Implements IMessageFilter.PreFilterMessage
Return OnInside()
End Function
Private Function OnInside() As Boolean
Dim _inside As Boolean = True
If InsideEvent IsNot Nothing Then
InsideEvent(_inside)
End If
Return _inside
End Function
End Class
This is the code on my form :
Dim filter As New MyMessageFilter()
Private Flag1 As Boolean = True
Private Sub filter_Inside(ByRef value As Boolean)
value = If((Groupbox1.ClientRectangle.Contains(Groupbox1.PointToClient(Control.MousePosition)) AndAlso Flag1), True, False)
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles Me.Load
AddHandler filter.Inside, AddressOf filter_Inside
Application.AddMessageFilter(filter)
End Sub
This works , but I have some problems :
1)
I have a main form with menu and several other forms. On one of this forms ( not main) I have implemented Imessage filter. But when I close this form , I get an error on this sub :
Private Sub filter_Inside(ByRef value As Boolean)
value = If((GroupBox1.ClientRectangle.Contains(GroupBox1.PointToClient(Control.MousePosition)) AndAlso Flag1), True, False)
End Sub
: An unhandled exception of type 'System.ObjectDisposedException' occurred in System.Windows.Forms.dll
Additional information: Cannot access a disposed object.
What can I do ?
2)
I have noticed a problem in a groupbox that have bound controls.
I have a button that delete records from this form.And if the last record is deleted , I set the flag1 for the GoupBox1 to true ( so not clickable).
but on runtime , when I delete the last record , the bound textboxes should become empty. But they become empty only when I move the mouse outside the groupbox1. ( I didn't have this problem before implementing Imessage filter for this groupcontrol )
What can I do ?
Thank you !
|
|
|
|
|
I told you this wasn't going to work for you without a LOT of work. You're using a sledge hammer to kill a fly.
1) The reason it's telling you the object is disposed is because the filter is still running, but the GroupBox doesn't exist any more. If you Close and Dispose the form, the GroupBox is destroyed, so there's nothing to get a ClientRectangle from!
2) If you called Delete, you TAGGED the record in your DataTable for delete. It does NOT get deleted until you or something else calls AcceptChanges on either the DataRow you deleted or on the DataTable that contains it.
|
|
|
|
|
Thank you !
1) Is possible to use Application.RemoveMessageFilter(filter) on the form's closing method ? Can this resolve the problem ?
2) I call all the methods needed because before implementing Imessage filter everything was worked. But after implementing the imessagefilter on the Groupbox that contain the bound controls , I have this problem. After pressing the delete button , I have a Messagebox to confirm the deletion , and after pressing "Yes" , the mouse pointer remain inside the groupbox . Only If I remove the mouse outside the controls become empty. What can I do ?
Thank you !
|
|
|
|
|
hi everyone,
i need your help!
i successfully merge 3 columns to one column in datagridview but the problem is, there is no spaces between the merged data. And also how to separate data by "/"? My data base is sql and i'm using vb.net2008
thank you in advance
<code>
Dim con As New SqlConnection
Dim cmd As New SqlCommand
con.ConnectionString = "Data Source=192.168.xx.xx;Initial Catalog=directory1;Persist Security Info=True;User ID=me;Password=cute"
cmd.Connection = con
con.Open()
Dim qr As String = "SELECT names,(dept + div + pos) as dept_div_pos, tel, local FROM directory1"
Dim ds As New DataSet
Dim da As New SqlDataAdapter(qr, con)
da.Fill(ds, "directory1")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "directory1"
con.Close()
</code>
modified 30-Apr-14 3:06am.
|
|
|
|
|
separate by space
dept + ' ' + div + ' ' + pos
separate by /
dept + '/' + div + '/' + pos
|
|
|
|
|
|
You are welcome. Please accept it as answer. according to CP instruction : "If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you." Thanks.
|
|
|
|
|
Hi. So I know I've done this before but I can't get it to work despite every example on the internet telling me it should... I'm trying to call a procedure from code. I keep getting an "Invalid SQL statement" exception. Any ideas why? And yes, the procedure compiles and gives no errors when calling from an oracle client.
create procedure DoSomething
as
begin
end DoSomething;
I try to execute from code like so:
Using conn = New OracleConnection(MyConnectionString)
Using cmd = conn.CreateCommand()
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "DoSomething"
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
End Using
End Using
At which point I get the aforementioned exception.
What am I doing wrong?
Sam.
|
|
|
|
|
Does it work when you execute the stored procedure through Oracle?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Yes. This is a only a problem calling the procedure from code.
|
|
|
|
|
You have already posted this question in the Database forum[^].
You've been here six and a half years, and you still haven't realized that cross-posting questions isn't acceptable behaviour?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Oh, I'm terribly sorry that I added another few hundred duplicate bytes the massive amount of data stored here. However will this site possibly be useful now that I've completely gummed it up????
What in incredibly silly thing to get upset about. Report me to the admins, quick!
BTW, since I don't actually know the traffic on the individual discussions and since this question very clearly spans multiple topics, I don't see the problem here. So if you don't like my post and have nothing to contribute other than being a pompous jerk, feel free to pass over my posts.
|
|
|
|
|
USAFHokie80 wrote: Oh, I'm terribly sorry that I added another few hundred duplicate bytes the massive amount of data stored here. However will this site possibly be useful now that I've completely gummed it up????
WRONG. What you've done is place the same question in multiple places, splitting up the possibility of getting a collaborated answer. Now the answers you get could possibly conflict with each other, confusing YOU.
This has nothing to do with the number of bytes you posted.
USAFHokie80 wrote: BTW, since I don't actually know the traffic on the individual discussions and since this question very clearly spans multiple topics, I don't see the problem here. So if you don't like my post and have nothing to contribute other than being a pompous jerk, feel free to pass over my posts.
By the error message alone, it's only a database question. It has nothing to do with VB.NET or C#. It's simple. Something in the string you built and sent to Oracle wasn't correct. Since you didn't show the complete statement you sent, it's impossible to tell you what you did wrong.
|
|
|
|
|
Thanks for the concern, but I think that I'm probably the best one to decide what is or isn't confusing to me.
As for the error, you apparently don't understand. The procedure signature is identical to what I've posted. Only the name of the procedure is different. And as I stated, the procedure itself works perfectly well when executed from SQLLite command line client as "execute DoSomething;". So the problem actually is with the way it's being called from code and -not- the database. That is the complete statement, again, with only the actual name changed.
|
|
|
|
|
Wow. It's all about how this affects you and you alone, isn't it.
USAFHokie80 wrote: The procedure signature is identical to what I've posted. Only the name of the procedure is different. And as I stated, the procedure itself works perfectly well when executed from SQLLite command line client as "execute DoSomething;". So the problem actually is with the way it's being called from code and -not- the database.
If all you're doing is calling the procedure by name and not passing any parameters (which your code suggests,) the error is in the stored procedure.
|
|
|
|
|
I cannot see how my asking this question could negatively affect anyone. It seems like people on here, like most of the internet, just want to complain about something. This is tantamount to chastising me for using an incorrect homonym in my sentences.
And once again, the procedure runs flawlessly when execute from an Oracle client. If there were a problem with the code in the procedure I would have gotten an error. But, just to satisfy this useless endeavor, I'll indulge you.
create or replace
procedure UpdateUnitType as
cnt number(10,0):=0;
begin
for u in (select * from unit where type_cd = 1)
loop
cnt := 0;
select count(billet_id)
into cnt
from billet
where fiscal_year = u.fiscal_year
and uic = u.uic;
if cnt > 0 then
update unit
set type_cd = 2
where unit_id = u.unit_id;
end if;
end loop;
end updateunittype;
|
|
|
|
|
USAFHokie80 wrote: If there were a problem with the code in the procedure I would have gotten an error. But, just to satisfy this useless endeavor, I'll indulge you.
Don't ever assume this. What you're doing in the "client" is not exactly the same as what you're doing from code. Also, what you do in the stored procedure declaration can also affect what you have to do in your code depending on which provider library you're using.
For example, "CALL stored procedure name" in the "client" will not work if you're using Oracle's ODBC provider, but it works if you use MS's ODBC provider in your code.
What does the connection string look like?
|
|
|
|
|
He tried to help you....
End of the story.
|
|
|
|
|
Hai,
Am working windows application and using list view control but i can't increase row height. Please help me. very urgent.
Thanks
D.Manivelan
|
|
|
|
|
Good Day Sir/Mam
I would like to ask if there is an ocx/dll/third party sotfware for visual basic that checks a grammar in a text and can be use to a 64bit windows OS.
Any suggestions will much appreciated. Thank you.
modified 25-Apr-14 4:52am.
|
|
|
|
|
Many many moons ago I recall we used the Microsoft Word API to achieve this - it was a bit of a PITA though. Bear in mind that a VB6 program will not be using 64bit windows though - it will run under WOW64 - i.e. 32bit.
|
|
|
|
|
VB.net is not my strongest forte but I posted this solution http://www.codeproject.com/Answers/764387/TextBox-BackColor-Change#answer4 to a post and it's been downvoted. I don't care about the downvote but I do care if I've led the OP and others astray. Basically I suggested using one function to handle all of the Enter and Leave events...is that bad practise?
|
|
|
|
|
If it does not affect your program execution then probably no. However each event serves a specific purpose and should maybe treated as that.
Edit:
I just had a quick look at your suggestion and there is absolutely nothing wrong with what you suggested. The upside of that is it reduces the amount for coded lines and since there are 6 textboxes why on earth would I want to navigate past 5 identical Sub's each referring to another similar control.
You probably got down voted by a noob who does not really know what all that means.
|
|
|
|
|
Thank you! I've already thanked Richard Deeming as well on his comment to my solution post (which is handy if anyone comes across it)
|
|
|
|
|
I don't see anything wrong with your answer. It's certainly better than any of the others!
Edit: Apart from the fact that you're relying on Option Strict Off ; you should probably add a DirectCast in the handlers.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|