|
Do you not know how for each works ?
foreach(CheckBoxListITem item in myBox.Items)
{
item.Checked = true;
}
I am sure that's not the type of the items, but that's how it looks.
Christian Graus - C++ MVP
|
|
|
|
|
you can you this too
<br />
for (int i = 0; i < this.checkedListBox1.Items.Count; i++)<br />
{<br />
this.checkedListBox1.SetItemChecked(i, true);<br />
}<br />
Regards
Shajeel
|
|
|
|
|
It doesn't matter what it is, having a check box that says 'select all' makes no sense, it should be a seperate control to the type of control that is being selected ( and probably a button )
Christian Graus - C++ MVP
|
|
|
|
|
My example doesn't say "Select All" it just says All like:
Which fields do you want to search:
[ ] All
[ ] Author
[ ] Text
[ ] Date
[ ] Etc.
Granted you could write the same thing with radio buttons or something, like:
( ) All
( ) Selected
[ ] Author
[ ] Text
[ ] Date
[ ] Etc.
But I'd say the first one makes equally as much sense to most users, especially when it selects all the other check boxes.
It's just a shortcut, in either case.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Hello Everyone,
I am trying to pass two dates to a stored procedure in SQL server. I only require the date protion of the input not the time, but I cannot seem to get the formatting to just mm/dd/yyyy
the data is collected from two text boxes on a web form and is imput as string in the format mm/dd/yyyy.
The SP is expecting datetime parameters.
I have tried so many variations to this I am wondering if it can even be done????
DateTime FromDate = DateTime.ParseExact(tempdt, "mm/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
DateTime Todate = Convert.ToDateTime(ToDateLbl.Text);
None of these work.
All help grealy accepted.
|
|
|
|
|
Jagannatha108 wrote: DateTime FromDate = DateTime.ParseExact(tempdt, "mm/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
Change "mm/dd/yyyy" to "MM/dd/yyyy"
|
|
|
|
|
Sorry Jon, this still did not format my date to MM/DD/YYYY.
string tempfrmdt = FromDateLbl.Text;
string tmptodte = ToDateLbl.Text;
DateTime FromDate = DateTime.ParseExact(tempfrmdt, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
DateTime Todate = DateTime.ParseExact(tmptodte, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
Retuned the date as mm/dd/yyyy hh:mm:ss, not what I need.
Thanks for the suggestion though.
|
|
|
|
|
So, essentially you just need a string representation of the DATETIME parameters in the sproc? You can just use the CONVERT() T-SQL function to do that.
SET @varcharFromDate = CONVERT(VARCHAR(10), @FromDate, 101)
SET @varcharToDate = CONVERT(VARCHAR(10), @ToDate, 101)
Is that what you're asking? If not, then I'm not exactly clear on what the problem is.
|
|
|
|
|
So what your saying is...
Change,
ALTER PROCEDURE dbo.ShortCallsDateRange
(
@FromDate DATETIME,
@ToDate DATETIME,
@CallCount INT OUTPUT
)
AS
BEGIN
SELECT @CallCount = Count(*)
FROM HD_Call
WHERE (CONVERT(DATETIME, dateraised, 101) >= @FromDate AND (CONVERT(DATETIME, dateraised, 101) < @ToDate));
SELECT call, status, assignee, dateraised, shortrequest, shortaction
FROM HD_Call
WHERE (CONVERT(DATETIME, dateraised, 101) >= @FromDate AND (CONVERT(DATETIME, dateraised, 101) < @ToDate))
END
RETURN
To
ALTER PROCEDURE dbo.ShortCallsDateRange
(
@FromDate VARCHAR,
@ToDate VARCHAR,
@CallCount INT OUTPUT
)
AS
BEGIN
SELECT @CallCount = Count(*)
FROM HD_Call
WHERE (CONVERT(VARCHAR, dateraised, 101) >= @FromDate AND (CONVERT(VARCHAR, dateraised, 101) < @ToDate));
SELECT call, status, assignee, dateraised, shortrequest, shortaction
FROM HD_Call
WHERE (CONVERT(VARCHAR, dateraised, 101) >= @FromDate AND (CONVERT(VARCHAR, dateraised, 101) < @ToDate))
END
RETURN
Sorry for being confusing.
I was not sure if I could do the convert thing with datetime variables from C# to Sproc.
I will give it a go now.
Thanks for your persistent patients.
|
|
|
|
|
Ok, now that I have seen the code, I think it is better that you leave it as it is.
In your C# calling code, do this:
DateTime FromDate = DateTime.ParseExact("11/22/2006", "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
DateTime ToDate = DateTime.ParseExact("11/30/2006", "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
ToDate = new DateTime (ToDate.Year, ToDate.Month, ToDate.Day, 23, 59, 59);
(Of course, replace my dates with your variables that you're trying to convert.)
This will give you a FromDate of "11/22/2006 00:00:00", and a ToDate of "11/30/2006 23:59:59", which I assume is what you want. So, any value in the dateraised column that is between 11/22/2006 and 11/30/2006 inclusive will be returned.
Edit: You'll may need to change "< @ToDate" to "<= @ToDate" in your sproc, depending on how your logic works.
|
|
|
|
|
My Senior Design Group for school recently purchased a pair of Xpress Ethernet Bridges. On one end, we will have a single board computer aboard a robot while the other end is a laptop. 1 Ethernet bridge is connected to the laptop and the other is onboard the robot. I have a GUI started in C#.NET and now I am trying to send data to and from the robot via these ethernet bridges. I am able to send data if I connect two computers to the internet, however when i use the ethernet bridges(not connected to the internet) I am unable to send data to and from the robot and laptop. Im not asking for anyone to write any code for me, I am just curious if you can turn me in the right direction.
If I need to supply more info or current code, I can post that as well.....
Thanks!!
|
|
|
|
|
Sorry I cannot help you out, but just wanted to say that your project sounds very interesting and wish you the best of luck with it
Some people have a memory and an attention span, you should try them out one day. - Jeremy Falcon
|
|
|
|
|
do they definitely connect to each other via tools other than c#?
have you tried all the stuff like pinging the robot from the commandline?
I assume that both machines have picked up valid IP addresses on the same subnet and aren't sitting there searching for dhcp servers or similar.
HTH
Russ
|
|
|
|
|
OK, you know the .resx files created for every form, control, etc that has resources stored in it(ie. strings, images, etc)? Well, what I need to do is to make a component that would essentially feature a design time property dialog, aloowing me to add items to this component. Just simple items - name and value, both strings. What it would do then, is save this list of values to the .resx file of the form or control on which this component would reside. I have absolutely no idea where to begin with this, so any help at all is appreciated.
Hrm, I also need it to write to those .resx files, not some other place - the application is localizable, so whichever is the current culture selected, thats where it writes.
Sorry if that sounded too demanding, but I'm rushing this.
Thanks in advance,
Anton.
|
|
|
|
|
Hi all,
i am using a clasic low-level hook for the keyboard and runing it in the main class:
kBHook = new KeyBoardHook();
kBHook.KeyPress+=new KeyPressEventHandler(kBHook_KeyPress);///
kBHook.KeyDown+=new KeyEventHandler(kBHook_KeyDown);
kBHook.KeyUp+=new KeyEventHandler(kBHook_KeyUp);
so KeyBoardHook is another class on my project.
it happens that when my program is busy doing calculations the keyboard class misses KEYUP/KEYDOWN messages.
so my questions are:
1. how can i make another thread that always listen to messages?
2. can i try to hook to keyboard in a way that i will always get the messages (i need my program to get those msgs before others)
Thank you,
R.Z
|
|
|
|
|
I'm not sure about #2, but for #1, the only thing you'll most likely need is to set the apartment state of the thread to STA. You can do this using the SetApartmentState method on the Thread class.
|
|
|
|
|
Hi, thanks for quick reply.
i don't start my program as a Thread t=new Thread...
the program's thread starts like this (and it is STA) :
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
any ideas?
R.Z
|
|
|
|
|
Sounds like the keyboard hook class is not functional. couple things to check: if you're using native Win32 hooks, I assume you have a callback function? Well, your delegate to that function must be manually kept alive, IRRC.
Aside from that, all I can suggest is narrowing the problem down: are you sure it only occurs after work is occurring? Are the events not being sent at all? what happens after the work is completed, do the hooks resume working?
|
|
|
|
|
my keyboard class is supposed to prevent keys from being sent to the current active window.
when there is no heavy work on my program it blocks all chars and Notepad do not show any chars.
when i write (for testing) Thread.Sleep(1000) in the KeyDown event in the main program , Notepad then display the characters even that i blocked them (return 1 on the hook).
i have seen then even if my Hook gets the message later, the Notepad already displaying the char.
this is the main core of the listening:
KeyboardHookProcedure = new HookProc(KeyboardHookProc);
hKeyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL, KeyboardHookProcedure, Marshal.GetHINSTANCE( Assembly.GetExecutingAssembly().GetModules()[0]),0);
the SetWindowsHookEx defined like that:
[DllImport("user32.dll", harSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall, etLastError=true)]
private static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);
Whats is IRRC and how do i do that?
Thanks,
R.Z
|
|
|
|
|
IIRC is "if I recall correctly".
When you pass a delegate instance in for the lpfn parameter of SetWindowsHookEx, make that delegate be a field in your class so that it doesn't get disposed; as I recall, since the object is being passed into a native method, then never used again, the garbage collector cleans up the delegate, causing your hook to fail. So one thing to check is make sure the delegate you pass into SetWindowsHookEx stays alive.
Windows may have some mechanism so that if the process eating the keyboard is not responding (i.e. busy do to lots of work) it may send out the key events to other processes. Can you make your work occur on another thread, thus keeping the hook procedure thread free? That'd be ideal.
|
|
|
|
|
This is the error message:
(0,0): error CS1705: Assembly 'Common, Version=1.0.2516.28982, Culture=neutral, PublicKeyToken=null' uses 'Eng.Common, Version=2.0.1623.14765, Culture=neutral, PublicKeyToken=0989625e39e31c91' which has a higher version than referenced assembly 'Eng.Common, Version=2.0.131.0, Culture=neutral, PublicKeyToken=0989625e39e31c91'
in the object browser it shows both versions of this dll...
How can I overcome this problem?
Thanks,
Jim
|
|
|
|
|
You need to use the version that is matching what your application is looking for. Currently, your application is using version 2.0.131.0 and you are referencing version 2.0.1623.14765!
|
|
|
|
|
Quick question on remoting. If I have a remote object which has a property that is read/write, is there a way to enforce it such that only the host that published the object has write access to a property and only the client has read access. Or vise-versa.
|
|
|
|
|
Are you talking about something like this?
IPrincipal principal = System.Threading.Thread.CurrentPrincipal;
if (! principal.IsInRole(machinename + @"\RemotingUsers"))
{
throw new UnauthorizedAccessException("The user is not in group RemotingUsers");
}
|
|
|
|
|
You can also check the IPFilter example in the sdk.
|
|
|
|
|