|
One way to handle this is to convert the Custodian field's NULL value to an empty string in the SQL Server database instead of trying to do it in C#:
SELECT ISNULL(Custodian, '') AS Custodian
WHERE ...
|
|
|
|
|
I dont think the dot is needed between Rows[0] and custodian...
if (Tables[FormList].Rows[0]["Custodian"] == DBNull.Value ){
strColumnValue = "";
}
else {
strColumnValue = Tables[FormList].Rows[0]["Custodian"];
}
give it a try and let me know.
|
|
|
|
|
Thanks for your suggestion as it does seem to get rid of the previous error. However, now the FormList table reference isn't recognized when I set the strColumnValue. I'm just going to do the conversion within SQL as I don't have time to turn this problem into a mini-project. .NET _is_ incredibly complicated; I hope Microsoft understands that we can't take years and years just to learn this object model, especially when there are so many different ways to do things.
|
|
|
|
|
I'm having a bit of a tick trying to implement a delete menu item (such as on an edit menu) To this point I've implemented it by using SendMessage to send a WM_CLEAR message to the active control on my form, but this doesn't act as per a normal delete menu item. If there is a selection in the control it gets deleted, but if there is no selection then nothing happens, when it should in fact remove the character directly behind the caret. Any information on how I could achive this functionality would be appreciated.
I wouldn't mind checking the textbox to see if any text is selected and if not then simply selecting one character from the current caret position forward, but I don't know how to find out the caret's position in the textbox, if anyone knows how to do this I couldn't implement the rest without a problem.
Thanks.
- Aaron
|
|
|
|
|
I hope this is what you want. If you know the TextBox with the focus (that is, the caret in it), then you can put the following code in your MenuItem event handler. This assumes that the name for the active TextBox is textBox1 .
int n = textBox1.SelectionStart;
if( textBox1.SelectionLength > 0 )
{
textBox1.Text = textBox1.Text.Remove( textBox1.SelectionStart, textBox1.SelectionLength );
if( n > 0 )
{
textBox1.SelectionStart = n;
}
}
else if( textBox1.Text.Length > 0 )
{
string t = textBox1.Text;
if( n > 0 )
{
textBox1.Text = t.Substring( 0, n - 1 ) + t.Substring( n );
textBox1.SelectionStart = n - 1;
}
}
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
That looks like exactly what I'd need, except I think I'd want n+1 in the first SubString method call because I want to delete the character after the caret.
Thanks very much for the information and the informative piece of code.
- Aaron
|
|
|
|
|
My pleasure. Happy coding!
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hello,
I'm currently writing a tool to manage sticky notes displayed on desktop. But I have a problem with "Show Desktop" option of Windows (WIN+D or icon in the taskbar). This option hide all notes displayed on the desktop; I know, it's normal. But does someone know a way to get ride of this??? Tanks a lot for your help!
Julien
|
|
|
|
|
You know, I had a lot of fun messing around with WndProc, only getting a subset of the functionality that you wanted. Then, I used the search string "c# open source sticky notes" with Google. Lo, and behold, the third option down, I found Stickies for Windows, an implementation of what you want released under the MIT open source license.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
How to I can obtain a list of all computers of a domain (without Active Directory) ???
Thankz
|
|
|
|
|
|
Tonster101 wrote: If you need further instructions, email me
It is better etiquette to keep answers on the forum so that everyone benefits.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
|
|
|
|
|
Thanks for sharing your etiquette snippet, but I think I can make up my own mind how best to be contacted, thanks.
~Tony Y.
|
|
|
|
|
It wasn't a comment about "how best to be contacted" It was about sharing information so that everyone benefits.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
|
|
|
|
|
How to I can know in that remote computer beginning session a X user? In Visual Studio 2005
In a domain without Active Directory.
Thankz
Sorry for my english
|
|
|
|
|
Hi!
I need to make somehing like this! For example: 4 forms, and 4 buttons where there is one button on each form!
When i press button on 1st form, that form is hiding or closing, and second form is showing! When i press button on second form, that form is closing and form 3 is showing, and so on ( when i press 4th button, first form is showing)! I don`t need circular moving! The moving have no rules! It can be first jumps to 4th... How can i control the moving thru program!? Do i need to make some method, like moving control or something!? What is the best solution!? Do i need to make a new instance of the form every time i calling that form or i can do something else! Thanks
|
|
|
|
|
What you want is fairly easy to do.
Each Form already has a ".Visible" property, which you can use to show one form and hide all others.
Each form should get a member "NextForm" which is initialized to the form to be shown when the button on the form is clicked.
In the button handler, hide the current form, and show the next form.
Your main program just needs to initialize the forms, chain them together (by setting nextForm), and you are done.
However, you might consider using a Wizard as this is the typical user interface
We say "get a life" to each other, disappointed or jokingly. What we forget, though, is that this is possibly the most destructive advice you can give to a geek.
boost your code || Fold With Us! || sighist
|
|
|
|
|
Wizard!? I`m not sure i understand what you are talking about! Can you explain me on some example!? When i initialize the forms
Form1 f1 = new Form1();
Form2 f2 = new Form2(); and so on, later, in code, when i type f2.show(); or on Form2, when i type f1 or any f(f3,f4..), i get an error message:
The type or namespace name 'f1' could not be found (are you missing a using directive or an assembly reference?)
|
|
|
|
|
If you want to keep track of your forms, try implementing a cache which will contain all forms.When you want a specific form you simply retrive it from the cache and show/hide/manipulate.
Hope this help.
|
|
|
|
|
How to I can unlock users account of a domain (without Active Directory).
In Visual Studio 2005 ??
Thankz
|
|
|
|
|
how to kill a remote process in Visual Studio 2005 ???
Is a Domain without Active Directory.
Thankz
|
|
|
|
|
Hi
I'm creating a component inherit from Panel under the .NET Framework 2.0 in C#. This component have a title bar in which I draw a text.
I would like to allow other developper who will use my component to edit this text directly via the designer and not only by the propertygrid. For exemple, I would like to do the same thing than in a Menu where you can write the title of your MenuItems in the designer.
Is there anybody can help me ?
|
|
|
|
|
I am trying to write a small web server that will receive POST's.
The data being sent to me does not include length in the header so I just need to read the socket until it no longer has any data. I have tried setting it up by adding this to my current code.
I started with the following which works for small items.
Int32 bytesRead = sock.Receive(byReceive, byReceive.Length, 0);
Then I added a while loop.
Int32 bytesRead = sock.Receive(byReceive, byReceive.Length, 0);
while( bytesRead > 0 )
{
bytesRead = sock.Receive(byReceive, byReceive.Length, 0);
} I have looked at lots of examples that are either too simple or too complex.
I never get out of the while loop.
Anyone have any example code or know where one is?
|
|
|
|
|
Did you try using the Available[^] property instead of (bytesRead > 0)? Also, make sure that the last Receive requests exactly Available bytes, otherwise the socket will block trying to receive byReceive.Length.
int bytesToRead = 0;
while ((bytesRead = sock.Available) != 0)
{
int bytesToRead = Math.Min(bytesRead, byReceive.Length);
sock.Receive(byReceive, bytesToRead, 0);
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Yes, I ended up trying some thimg very similar
do
{
bytesRead = sock.Receive(byReceive, byReceive.Length, 0);
totalRead += bytesRead;
Thread.Sleep(100);
strRetPage = strRetPage + Encoding.ASCII.GetString(byReceive, 0, bytesRead);
}
while( sock.Available > 0 );
Now the problem is that without the Sleep it reads the socket once and bails out.
Another problem is that 10% of the time the socket claims to be empty and receives nothing.
I have little hair left to pull out
-- modified at 21:17 Thursday 22nd December, 2005
|
|
|
|