|
ups, i misstyped the second line!
it should be
myinput = String.Format("{0,10}", myinput}
and i already found out, it ignores the formating, if the string is longer than defined in the formatsring. so i have to check it myself, by splitting off the relevant position in the format string to compare it to.
modified on Monday, May 5, 2008 9:10 AM
|
|
|
|
|
I believe it will throw an exception..even sql server throws an exception that warns that string data is bieng truncated. your best solution would be to either limit what the user can type in, or check its length before you try to insert it, and either truncate it yourself, or tell the user that the input is invalid(best solution so the user doesnt get bad data in the db or where ever you're putting it)
|
|
|
|
|
the user wants this behaviour:
if the string is smaller or equal the length defined in the format string, then just insert it, if it is longer than the length defined, then the programm should throw a worning, but insert the data anyway.
i have to insert it into a stream. so if it is too long, then all other info is moved x characters to the right (x is the difference to the defined and the real length).
well, because it just ignores the length if it is too long, i have to write a check myself to know, if i have to throw a warning or if the length is ok.
|
|
|
|
|
you should probably try to explain to the user that just inserting the data even if its too long is a bad idea. you could just use the string.Length to find out how long it is, and use Remove to cut off any unwanted characters
|
|
|
|
|
Dear all,
I am building a c# application. I wanted to add to it the capability that i dictate a URL and then write it in a text box, so i searched and i found that i should use class "DictationGrammar". However i couldnot find an intact example or set of steps to follow to build the required utility. I would appreciate it if anyone could help...
Regards,
|
|
|
|
|
Hi All
I Wount to use the workflow project , but i dont know who i can do ...
who can hellp me ?
thank for any body hellp me
Thaer
|
|
|
|
|
Please read the forum guidelines.
|
|
|
|
|
Hi,
on My form I have about 150 controls at the same time, and most of them use docking.
some of them are childs in childs in childs of controls.
Whenever I resize my form it takes a long time for it to rearrange and ready to workwith.
I manged to speed up things in the proccess of adding all the controls by using ResumeLayout and SuspandLayout. But what should I do in the proccess of resizing?
How can I find out when the resizing event startend and when the resizing is finished?
tnx leeoz
|
|
|
|
|
Resize event doesn't quite work like that, it gets fired when the forms size has changed. So when you resize your form with your mouse, every time you see a visible change in the size of your form, then event has been fired.
Sadly you can't get the mouseDown mouseUp events for clicking on the border. The only way i know to get that information is to override WndProc and look at the messages, one of them is sent when you mouse down on the caption bar/border and other are sent when the mouse moves or the button is released.
But, i tried using SuspendLayout and ResumeLayout with docked controls, and i think after ResumeLayout the controls just stayed where they were. So you should check that.
Good news is though, if you also override the OnPaint event you can stop any drawing yourself. So if you use WndProc to work out when the form is being resized then you can set a bool to false or something, and have an if statement around base.OnPaint(e); in your OnPaint override. Of course even without drawing it will still try to reposition all of the controls every time the resize event is fired, so it may still end up going slow.
Well, good luck.
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
Hello. I have to open an outlook item using the hyperlink like <Outlook:Sent Items>. This technique is described here http://support.microsoft.com/kb/225007. As i understand, such links are to work in the explorer address bar as well. But instead, IE just can't display the page. Could anybody explain how it should work?
Than's in advance.
|
|
|
|
|
Well i just tried it and it does work, but IE doesn't show the page. Outlook just opens on the Sent Items folder. And just in case, you don't actually type the <> signs.
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
Very strange, because it does not work with my configuration. Could you please tell me what Outlook and IE versions you use? I have IE6 and Outlook2007 installed. Thank you.
|
|
|
|
|
IE6 and Outlook 2003. And i just checked in FireFox, it works there too.
My current favourite word is: Bacon!
-SK Genius
|
|
|
|
|
Thank you very much. I have just tested it with Outlook2003 and it works fine. The problem is in Outlook 2007.
|
|
|
|
|
Public AsynCallback pfnWorkerCallBack; //Define a global reference
public void WaitForData(System.Net.Sockets.Socket soc,int clientNumber)
{
try
{
if( pfnWorkerCallBack == null )
{pfnWorkerCallBack = new AsyncCallback (OnDataReceived);}
SocketPacket theSocPkt = new SocketPacket (soc, clientNumber);
soc.BeginReceive (theSocPkt.dataBuffer, 0,
theSocPkt.dataBuffer.Length,SocketFlags.None,pfnWorkerCallBack,
theSocPkt);
}
}
public void main()
{
WaitForData(Socket1,1);
WaitForData(Socket2,2);
}
Question:
1.When the 1st WaitForData(Socket1,1) started, pfnWorkerCallBack is definitely equal to NULL so a new AsynCallback is created and assigned to pfnWorkerCallBack. What happen to pfnWorkerCallBack when the second WaitForData(Socket2,2) started?
2.When a same method was started asynchronously for several times. Are all method's variables refer to the same variables?
|
|
|
|
|
I have created a shared folder through Windows e.g. 'D:\Testing'
I have given permissions to 3 users A, B, C
Now, I want to access the names of these three users.
I am using GetSecurityDescriptor for performing this but,
the DACL returned by this function always contains 7 users
(out of 6 are default and 1 loggedin user) irrespective of shared permissions.
DDeepali
|
|
|
|
|
This is because there are two levels of permissions in play when you share a folder:
1. The permissions on the *folder* in the file system (NTFS). Accessible via the "Security" tab in the properties dialog box for the folder. These permissions are in effect even when you access the folder locally (not only via networking). The permissions are stored in the file system, and are what you get when you query the file system (NTFS).
2. The permissions on the *share* (accessible via the "Permissions" button on the "Sharing" tab). These apply only when accessing the share via the file server component (lanmanserver - which started its life as a port of OS/2 LAN Manager, hence the name) in the system. These permissions (along with the share name and other settings) are stored in the registry (HKLM, System, CurrentControlSet, Services, lanmanserver, Shares).
In order to access a file via a file share, you need the appropriate permissions on BOTH.
Most likely you are querying the file system, so you get the file system permissions. I suspect you have to use another API (or framework namespace) to find the share permissions (never done it myself).
Before Windows Server 2003 best practice (and default) was to grant everyone full control to the share and then control permissions in the file system. Most people still do that (as those permissions will be enforced even if users use other protocols/services to get at the files). The default configuration in WS2003 is to only grant everyone read-only access to new shares, though.
Confusing? Yes, but that's unavoidable. The file server has to be able to secure stuff residing on insecure file systems (such as FAT), and therefore needs an additional layer of security. When you use NTFS, however, there's not much point in using that layer - and as noted, most people tend to use "everyone, full control" at share level and then control access with the NTFS permissions.
HTH
--
Peter
|
|
|
|
|
Thanks alot for such a knowledgeable reply.
I will try to some APIs that can help me.
thanks alot
DDeepali
|
|
|
|
|
Thanks for the appreciation!
On a second note - my experience (20+ years of working with sysadmin tasks in various OSes) is that permissions should never be granted to users or organizational groups (groups that are based on peoples role's). The one way of achieving zero maintenance for folder/share permissions is:
1. Create a group (machine or domain local depending on scope of the resource) for the resource. Name it so that the resource and appropriate access is described, such as "Product presentations (modify)". Only create groups for permissions that are actually needed - otherwise, you'll end up swamped with unnecessary groups...
2. Grant the appropriate NTFS permissions to that group (as well as full control to SYSTEM and Administrators). Grant file share permissions accordingly (except for SYSTEM - not applicable at share level).
3. From then on - manage permissions by adding/removing users and/or user role groups to/from the resource group.
Not only will you never need to fiddle with file system and/or share permissions once they have been created, but you will also be able to delegate (assuming you use domain local groups) permissions management to someone who doesn't have access to the file system/share permissions. Also, it is somewhat simpler to script/automate group membership management than permissions management. You'll also never more need to see "account unknown" in an ACL after users have been deleted (if you use machine local groups and add domain users to them, you will see them in the group memberships instead - but not if you stick to domain groups).
Later,
--
Peter
|
|
|
|
|
<br />
namespace WindowsFormsApplication1<br />
{<br />
public partial class Form1 : Form<br />
{<br />
private List<Data> dataList = new List<Data>();<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
dataGridView1.DataSource = dataList;<br />
}<br />
<br />
private void addTToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
dataList.Add(new Data() { Name = "V", LastName = "J" });<br />
dataGridView1.DataSource = null;<br />
dataGridView1.DataSource = dataList; <br />
}<br />
<br />
private void FillData()<br />
{<br />
dataList.Add(new Data() { Name = "V", LastName = "J" });<br />
dataList.Add(new Data() { Name = "A", LastName = "B" });<br />
dataList.Add(new Data() { Name = "C", LastName = "D" });<br />
}<br />
}<br />
<br />
public class Data<br />
{<br />
public string Name { get; set; }<br />
public string LastName { get; set; }<br />
}<br />
}<br />
In the above code I try to add a data in the List through gridview by using context menu.
Its working fine if already List is populated by data.
But fails if I try to add a data without the List is populated.
Scenario on fail:
screen 1: Form with empty gridview is shown.
screen 2: I right click the gridview which show the context menu "Add", when I clicks addTToolStripMenuItem_Click method is called. which creates the data and adds in the list.
screen 3: The gridview with the one data is appearing.
scrren 4: When I tried to click on the cell ( i.e, newly created ). The error is getting thrown "IndexOutOfRange" -1.
Is I am missing any propeties to set.
Thanks in advance
Regards,
Vythees
Miles to go before sleep...
|
|
|
|
|
vytheese wrote: dataList.Add(new Data() { Name = "V", LastName = "J" });
dataGridView1.DataSource = null;
Hi, I haven't used this, but it seems to me the order of the above lines is wrong;
I would remove the bind, modify, then reinstate the bind.
|
|
|
|
|
Like this,
dataGridView1.DataSource = null;
dataList.Add(new Data() { Name = "V", LastName = "J" });
dataGridView1.DataSource = dataList;
I tried that too, Not working..
Regards,
Vythees
Miles to go before sleep...
|
|
|
|
|
Hi,
I have a few forms in my C# windows application. On main form, by a button, another form is shown. On this second form, by a button, another form is shown MODALLY ( ShowDialog() ). In such stiuation, when another application (ex: windows explorer) becomes activated, then my application reactivated using application-icons on windows Task Bar, my Main form appears on top and does not respond to user because another form is shown modally which actually does not appear.
In fact, here, when windwos' Alt-Tab browsing is used, it seems no problem.
How can I ensure the last opened form to bring to front in such cases?
I know it seems a small problem but really bothering..
Thanks for you help
|
|
|
|
|
You can test the following code snippets:
<br />
<br />
private void mnuAbout_Click(object sender, System.EventArgs e)<br />
{<br />
Form f = new Form();<br />
f.ShowDialog(this);<br />
}<br />
<br />
Anindya Chatterjee
|
|
|
|
|
Yes, setting the owner of a dependent form should do it.
|
|
|
|
|