|
It's very strange, speacially in only 3500 rows. Your code are pretty good.
As a sugestion, try to use a dataset to retrieve these values using a Data Adaptor to fill it. And then, set the datasource property of you list box. But i think this will not solve your problem, cause it's indirect access, and you have made simple access, which is faster.
good luck!
|
|
|
|
|
hey guys, ive wrote a little app that takes a given a IntPtr handle to a random application.... it when gets all childwindows and looks for the first EDIT (CEdit) class and then tries to set focus to it.. i know it seems pointless, but its part of a large plan! hehe
anyway, its just not working! im calling SetFocus(IntPtr) to the Edit class and its just ignore me! (ive even tried bringing the parent application to te front - that works btw)
any ideas why SetFocus isnt putting the cursor in the Edit class ready for user input?
|
|
|
|
|
Hello
Quoted from MSDN: If the hWnd parameter is invalid or the window is not attached to the calling thread's message queue, the return value is NULL. To get extended error information, call GetLastError.
Try to see the returned value, and GetLastError() .
Also I suggest to SendMessage(WM_SETFOCUS) yourself, instead of calling SetFocu(hWnd).
Regards
|
|
|
|
|
hi there,
when i use SetFocus(), it doesnt work and i get this last error message:
1008 An attempt was made to reference a token that does not exist. ERROR_NO_TOKEN
(i looked up the message on google)
however - if i do what u suggested it works
do you know why this way works and the other one doesnt?
|
|
|
|
|
Hello
I'm glad that it works now.
If you revise the qoute I posted from MSDN, you'd notice that SetFocus() function, sends the message to the current message queue. You are sending WM_SETFOCUS message to another application with another message queue. That's why you need to explicitly send the message yourself.
Regards
|
|
|
|
|
ahhhhh thats excellent!!
i understand it now!
thanks ever so much for your help this evening, its much appriciated!
Regards,
Will
|
|
|
|
|
Is there a way I can extract the extact data type strings but sql via ADO.NET.
I need to know the exact name of the data type from sql.
I tried creating a data table and filling it, then examining the columns. But, only gives me a .net data type. For instance, smalldatetime is converted to DateTime.
I need to know what it is before the conversion.
thanks
nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
you could try to perform a query which shows you the tables structure
( MySQL: desc Tablename; - Firebird: show table Tablename; ) and parse the
result in your programm. That way you would get the name of the datatypes used by your database.
|
|
|
|
|
Hi guys,
I have a ToolStrip control that is not redrawing properly. It seems to not be receiving a paint message when it should (ie if I bring any other window in front of it, it doesn't redraw). This is the structure it sits in:
- SplitContainer
- TabControl
- TabPage
- ToolStripContainer
- ToolStrip
It also doesn't redraw consistently when I switch between TabPages. Has anyone come across this before?
Many thanks,
Simon
PS This problem is occurring in a Windows Forms application for the desktop.
|
|
|
|
|
Hello
Yes. ToolStip control isn't supposed to redraw itself without having the focus- AFAIK-. This is normal.
Regards
|
|
|
|
|
Hi Nader,
Thanks for your reply. However, it does seem a bit odd because when I drag a window in front of Outlook the toolstrips there redraw perfectly well. Is there an obvious technique I should be aware of for forcing a redraw?
Many thanks,
Simon
|
|
|
|
|
Hello
It looks like I got your question all wrong!! Now I get what you mean.
Why doesn't your ToolStrip draw itself?? Doesn't it fire paint events?
To demonstrate that, I made the same cascade that you did, then I added a ListBox, and then the following code for each paint event in the cascade:
private void toolStripButton1_Paint(object sender, PaintEventArgs e)
{
listBox2.Items.Add("Button Paint");
}
private void toolStrip1_Paint(object sender, PaintEventArgs e)
{
listBox2.Items.Add("ToolStrip Paint");
}
private void toolStripContainer1_ContentPanel_Paint(object sender, PaintEventArgs e)
{
listBox2.Items.Add("Container Paint");
}
The listbox addes the item in the same order as the paint events should be fired. Al the Paint events are fired appropriately.
Try this demo in your code to see if the paint events are fired or not.
Regards
|
|
|
|
|
Thanks for your time on this Nader. I was hoping someone would say "Oh, that's a common problem and you just need to set property x". I was trying to avoid a full on investigation as I'm on a schedule with this thing. However, I will use your code and start digging into the problem to find out what's going on.
Many thanks again,
Simon
|
|
|
|
|
Am trying to dynamically build a tab, multipage and pageview
protected Microsoft.Web.UI.WebControls.TabStrip tc;
protected Microsoft.Web.UI.WebControls.MultiPage mp;
protected System.Web.UI.WebControls.Label txt;
Microsoft.Web.UI.WebControls.Tab tab=new Microsoft.Web.UI.WebControls.Tab();
Microsoft.Web.UI.WebControls.PageView pv= new Microsoft.Web.UI.WebControls.PageView();
//Am building a control here and adding it to pv
System.Web.UI.WebControls.TextBox txt= new TextBox();
txt.Text = "Microsoft";
pv.Controls.Add(txt);
pv.ID = id.ToString();
tab.TargetID = pv.ID;
Error: TargetID does not point to a valid PageView
the tab.TargetID has to be set to pv.(something).
can somebody help me on this?
rmr
rmr
|
|
|
|
|
Hello
First do not repost your question in the same forum even if you didn't get any answer. It's very rude. Delete the previous thread.
Second, to get an answer to your question you need to post this in the ASP forum not here.
Regards
|
|
|
|
|
Hello,
Its not that I dont know the basics of posting on forums, I needed to change the subject so that someone can help me out, I posted it again. Thanks for your advice and if you had helped me out, I would have told you double thanks.
rmr
|
|
|
|
|
Hello
I'd have happily helped you if I were an expert in ASP. There is a difference between C# and ASP. All I were capable of doing is pointing you to the right direction.
Regards
|
|
|
|
|
I create multiple STA threads and start them. Once I have started all the threads in my main thread I need to wait till all of them are done.
To wait I tried
WaitHandle.WaitAll() ----- returns exception
Tried
waitEvent.waitOne()
and thread.Join()
In above case some times my main thread slips through Join\waitOne(). (i.e. main thread does not wait till all other threads are done)
Please advice how to implement this?
My sample code is as below
Main()
{
...
...
ArrayList myThreadClass = new ArrayList(3);
ArrayList threads = new ArrayList(3);
for(int i = 0 ; i< 3;i++)
{
ThreadClass thClass = new ThreadClass();
myThreadClass.Add(thClass);
Thread myThread = new Thread( new ThreadStart(thClass.threadMethod));
myThread.ApartmentState = ApartmentState.STA;
threads.Add(myThread);
((Thread)threads[i]).Start();
}
for(int k = 0;k<3;k++)
{
((Thread)threads[k]).Join();
}
.....
.....
} //Main Ends
Some more info
In my thread method I do some COM calls and make some callls Writeline to StreamWriter
Sandeep Naik
|
|
|
|
|
Hello
You can go through your threads using a loop and check the IsAlive property of each
bool Finished = false;
while(!Finished)
{
Finished = true;
foreach(Thread T in Threads)
{
if(T.IsAlive)
Finished = false;
}
Thread.Sleep(100)
}
Otherwise you can check the ThreadState property
Regards
|
|
|
|
|
Will I be blocking message pump here ?
Sandeep Naik
|
|
|
|
|
I tried something like this and it works with some of my testing ..
Do you think if this correct ? or will there be any issues with this
for(int temp = 0; temp <threadcount;temp++)
{
thread mythread="(Thread)GRDumpThread[temp];
if(myThread.IsAlive)
{
waitEvents[temp].WaitOne();
}
}"
<div="" class="ForumSig">Sandeep Naik
|
|
|
|
|
Hello
Your code segments are inconsistent and somehow don't add up!! For example what is GRDumpThread??
Anyway, if you want to use WaitHandle class, you should register your threads in ther ThreadPool queue. Take a look at this example taken from MSDN:
using System;
using System.Threading;
public sealed class App
{
static WaitHandle[] waitHandles = new WaitHandle[]
{
new AutoResetEvent(false),
new AutoResetEvent(false)
};
static Random r = new Random();
static void Main()
{
DateTime dt = DateTime.Now;
Console.WriteLine("Main thread is waiting for BOTH tasks to complete.");
ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[0]);
ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[1]);
WaitHandle.WaitAll(waitHandles);
Console.WriteLine("Both tasks are completed (time waited={0})",
(DateTime.Now - dt).TotalMilliseconds);
dt = DateTime.Now;
Console.WriteLine();
Console.WriteLine("The main thread is waiting for either task to complete.");
ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[0]);
ThreadPool.QueueUserWorkItem(new WaitCallback(DoTask), waitHandles[1]);
int index = WaitHandle.WaitAny(waitHandles);
Console.WriteLine("Task {0} finished first (time waited={1}).",
index + 1, (DateTime.Now - dt).TotalMilliseconds);
}
static void DoTask(Object state)
{
AutoResetEvent are = (AutoResetEvent) state;
int time = 1000 * r.Next(2, 10);
Console.WriteLine("Performing a task for {0} milliseconds.", time);
Thread.Sleep(time);
are.Set();
}
}
Whatever you use, just make it work.
And for the method I posted earlier, yes it blocks your message pump.
Regards
|
|
|
|
|
Thanks for all your help... It was very use full
Sandeep Naik
|
|
|
|
|
Hello,
does anyone know how to make a true copy of the reference object to the new variable as if it was a value type?
An object is passed to my DLL from the application and I need to compare the object's contents between the calls.
Thanks much,
Michal
|
|
|
|
|
Hello
This epends on what type of reference object you are talking about. Each class implements a "Cloning" method accordingly. Some well known way of copying reference types -if available- are:
1- All classes derived from System.Object inherit a protected method called MemberwiseClone() . Remember this is protected, so you could use it if you inherit from that class only.
2- Some reference types override the = operator to perform copying of data rather than references. Known example is the System.String class.
3- Other types include a copy constructor where you could construct an object from the values of another.
Again if all the above is not available in your reference type, then you'll just have to make your own way of copying public members.
Regards
|
|
|
|