|
Your right, didn't realise.
Still learning, on week 1 and a half now.
At the point when I was learning how to use regular expressions I must have stumbled on to substring and assumed it was part of the namespace.
and I didn't know replace even existed
|
|
|
|
|
If you didnt understand his code above.
string trimmedFruit = fruit.Replace("\"", "");
its basically a \" in there so every " it finds it replaces it with "" // e.g. null
using the \ allows you to put a " in the string text
|
|
|
|
|
<blockquote class="FQ"><div class="FQA">haz13 wrote:</div>I have tried both char and string separators but can't think of a way grab the data cleanly without including a " or , . I either end up with "apple" "orange" "pear" or "apple orange pear"</blockquote>
I used similar code to split it. Heres some code, maybe it can help u.
Input text same as u : "apple","orange","pear" etc
assume the string named "str"
<pre>
string[] strArray = str.split(',');
for (int i=0;i<strArray.length;i++){
strArray[i] = strArray[i].trimStart('"');
strArray[i] = strArray[i].trimEnd('"');
}
</pre>
Training makes perfect....
|
|
|
|
|
I want to write a plugin for ms word.Is that possible in c#.
If the answer is yes , How?
Mori Nei
|
|
|
|
|
yes its possible. The correct term is "com add-in". Why not google ms word add-in c#, there are dime a dozen articles. Or visit msdn forums.
edit
try this link
http://www.google.com/search?lr=&ie=UTF-8&oe=UTF-8&q=ms%20word%20add-in%20c%23
|
|
|
|
|
Hello everyone,
I was wondering if someone can take a moment and explain to me the differences between DataTable and DataSet. I have been using both of them and to be honest with you, never undrestood the differences between them.
Maybe they have some specific differences which results in favoring one over the other when it comes to certain things. Saddly, I have never seen that and I use them in a random fashion. )
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
Easy. A DataSet is a collection of DataTable and DataRelation objects. You can have one or more DataTables in a DataSet. DataRelation objects just represent the relationships between related tables.
|
|
|
|
|
Hello Dave,
Thank you so much. Please don't laugh, but after your explaination alot of things made sence.
Once again, thank you very much for your help, mate.
Have a great day.
Khoramdin
|
|
|
|
|
I have a network application that runs in a thread for it self, my main application subscribes to the events the network application fires (such as SignedIn, ExceptionOccured and so on).
My problem is that when a event in the other thread if fired, I want to disable/enable and change a lot of stuff in my main application GUI.
But for every change I want to make in my main application, I have to write a delegate and invoke it.
This gives me A LOT of code that is only used once, and it just seems stupid.
Is there a way of executing a method with invoke without declaring a delegate?
I have an example to demonstrate my problem:
public class MyClass<br />
{<br />
<br />
public MyClass()<br />
{<br />
...<br />
myThread.SignOut += SignOut;<br />
}<br />
<br />
public void SignOut()<br />
{<br />
myForm.ShowLogin();<br />
}<br />
}
|
|
|
|
|
Not sure if this is what you're trying to accomplish but:
If using .NET 2 you can use an anoymous delegate which would perform the same function (internally the code is very similar) but the source code would look more readable.
pubilc MyClass()
{
myThread.SignOut += new YourDelegateTypeHere(delegate() { myForm.ShowLogin(); });
}
|
|
|
|
|
Thats better than what I'm doing now. Thanks!
If anyone else has some tips, you are welcome to post them.
|
|
|
|
|
When I'm doing a lot of cross thread operations I try to make my functions similar so that I can reuse their delegates as much as possible. If I have 10 functions that all have to be Invoked, only one delegate is needed if they all have the same return value and parameter list . . .
|
|
|
|
|
Yeah, that's what I was doing, but I don't like to do this because of the delegate naming and overhead of creating a delegate.
I found the perfect solution:
if (InvokeRequired)<br />
{<br />
MethodInvoker invoker = delegate<br />
{<br />
lblStatus.Text = message;<br />
};<br />
Invoke(invoker);<br />
}<br />
else<br />
lblStatus.Text = message;
With this I can execute cross-thread calls without creating a named delegate and a method for the delegate to call. Best of all; the code is readable.
|
|
|
|
|
I made a C# application and i want the Textbox control to just take numbers and no characters. In VC++ this can be easily done by setting a property.
Any idea how to do this in C#?
Thanks
|
|
|
|
|
Go for Validation control such that it should accept only Numbers.
Regards,
Satips.
|
|
|
|
|
You asked this question 3 days ago and got your answer. Asking it again will only get you ignored.
There are a ton of examples on how to do this on the web. You can create your own TextBox class by inheriting from TextBox, handling the KeyDown event and checking to see if the key pressed is numeric or not. You'll also have to make exceptions for the Delete and Backspace keys, plus the minus sign and decimal if you want your box to accept negative numbers and/or floating point numbers, without regard to culture I might add. You'll have to code your key filter to check what the culture specific number formatting characters are if you want it to support input from any culture other than English.
If you want it written for you, Google for "c# numeric textbox[^]".
|
|
|
|
|
use a maskedTextBox instead of textBox
|
|
|
|
|
Hi Guys,
I've got a WinForms DataGridView grid view setup in the following manner:
* 3 columns
* Columns 1 and 2 are readonly strings
* Column 3 is an editable int
* Column 3 is the shortest column
* The column sizes are fixed
* The DataGridView size is snapped to the total width of the columns
For some reason, regardless of what i do, column 3 always ends up in the middle, and column 2 at the end. I have even tried swapping them in the designer, but that displays as expected.
It's driving me nuts.
Has anyone encountered this problem before?
Cheers
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Tristan Rhodes wrote: Has anyone encountered this problem before?
Yes.
I don't think I solved it correctly, but what I did was:
Create the columns at run time and insert them in the order I wanted them to appear. Then when I bound the DataTable, everything appeared correctly. Make sure you don't have any columns without a position assigned (ie hidden column at column 1) interfering with your desired order.
Pualee
|
|
|
|
|
hi,
i want to list active directory users and same time get the login name of them...code are here..but gives an error here,
oResult.GetDirectoryEntry().Properties["cn"].Value
saying it is null...
code and path is correct because i can show oResults.Count saying it having
items..
My question is how to get userid and names...how to add properties to load DirectorySercher to get i
think it is not functioning...
here that i have coded.. im listing my code
im calling to method passing path like..
GetAllUsers("LDAP://test.lk/OU=sms,dc=test,dc=lk")
here is my code,...
public Hashtable GetAllUsers(string ldapServerName)<br />
{ <br />
string _ldapServerName = ldapServerName; <br />
DirectoryEntry oRoot = new DirectoryEntry(ldapServerName);<br />
DirectorySearcher oSearcher = new DirectorySearcher(oRoot);<br />
SearchResultCollection oResults ; <br />
Hashtable RetArray =new Hashtable();<br />
try<br />
{<br />
oSearcher.PropertiesToLoad.Add("uid");<br />
oSearcher.PropertiesToLoad.Add("givenname");<br />
oSearcher.PropertiesToLoad.Add("cn");<br />
oResults = oSearcher.FindAll();<br />
foreach (SearchResult oResult in oResults)<br />
{<br />
if (oResult.GetDirectoryEntry().Properties["cn"].Value.ToString()! "")<br />
{<br />
RetArray.Add(oResult.GetDirectoryEntry().Properties["uid"].Value,<br />
oResult.GetDirectoryEntry().Properties["cn"].Value);<br />
}<br />
}<br />
}<br />
catch(Exception e)<br />
{<br />
MessageBox.Show("Error is " + e.Message);<br />
return RetArray;<br />
}<br />
return RetArray;<br />
}
i oblidged u very much if u can provide me help on regarding..any resource
articles,sample code...
thanks in advance!
N:B
---------------------------------------------------------------------------
rootSearcher.PropertiesToLoad.Add(“name”); // Full name…
rootSearcher.PropertiesToLoad.Add(“mail”); // Primary email addy…
rootSearcher.PropertiesToLoad.Add(“telephoneNumber”); // Phone #...
like that i want to get the userID ?
plz.......tell me the correct statement for that ?
-- modified at 12:00 Thursday 14th June, 2007
|
|
|
|
|
Code looks OK. But what I guess you are getting some null value when you are adding it to hashtable.
You can try by putting a try catch block in foreach block
|
|
|
|
|
I have a Microsoft Access 2003 database with a .mdb extension with a table and a query on that table. In my query I have a parameter that allows me to get prompted within MS Access just before running the query.
The problem is when adding that .mdb file to my projects solution within VS I get prompted with the "Data Source Configuration Wizard" that shows the tables and views I can import. The view doesn't come up. Now if I take that parameter off and then try to import the .mdb file into my projects solution the view is there ready to be imported.
Do anyone know a workaround to import a query with a parameter?
Chris
|
|
|
|
|
Dear all,
I've got a directory full of files of the same type. Basically what they are CSV or TXT files. I would like to parse each individual file to a DLL for processing. I can select each individual file manually and process it :
<br />
private void btnGo_Click(object sender, EventArgs e)<br />
{<br />
string abd = "D:\\data\\File\\File1.csv";<br />
try<br />
{<br />
StreamReader rdr = new StreamReader(abd);<br />
while (rdr.Peek() >= 0)<br />
{<br />
dataGridView2.DataSource = CsvParser.Parse(rdr);<br />
}<br />
}<br />
catch (Exception)<br />
{<br />
MessageBox.Show("Error opening file.", "File Input Error",<br />
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);<br />
}<br />
}<br />
}
This works perfect, however if I have multiple files ( File0, File1, File2 .. etc ) I would like my method to loop through each file and process it. Is there an easy way of doing this.
Kind regards,
|
|
|
|
|
You can use Directory.GetFiles() to get all the files in the current directory. Then parse each file individually.
|
|
|
|
|
foreach (string fileName in Directory.GetFiles("path to the directory of files"))
{
}
|
|
|
|