|
|
Thx. I use NUnit all the time, do you like FXcop???
|
|
|
|
|
Any Regex guru's in the house?
I have a string coming from a database. This string represents some name/value pairs that are input by a Lotus Notes database and are delimited by two characters: '-' and ';'. The problem is the second part of the string allows both of the delimiters in the value field, so I can't use a Split(). What I need to do is first split the string to get the name/value pairs and then split it again to get the name and the value.
The string coming from the database looks something like this:
1234 - asdf-is a sample;2456 - eqwrt;7890 - ujk;l;097 - uio
And the array results should be something like so:
(I added the pipe symbol to make it easier to read)
1234 | asdf-is a sample
2456 | eqwrt
7890 | ujk;l;097 - uio
I can't figure out the syntax to split using a lookahead from the first '-' and the last ';' found before the next '-'.
|
|
|
|
|
I'm a little confused on your pattern here. The last name/value pair is what concerns me. You have it as:
7890 | ujk;l;097 - uio
But your own pattern suggests that this should be two pairs:
7890 | ujk;l
097 - uio
Is this a correct assumption on my part?
If it is, I did manage to find a way to separate this stuff out. What I did first was reversed the input string so it looks like this:
oiu - 790;l;kju - 0987;trwqe - 6542;elpmas a si-fdsa - 4321
Then I used the regular expression:
;?.*?\s*-\s*\d+
This yields the following:
oiu - 790
;l;kju - 0987
;trwqe - 6542
;elpmas a si-fdsa - 4321
If you remove the semicolon from the strings on which it appears and reverse them, it should work. You could also group the match and pull the contents of the group:
;?(.*?\s*-\s*\d+)
Logifusion[^]
|
|
|
|
|
Yeah, that was a typo on my part. Thanks for your help!
|
|
|
|
|
Also, if you know there are no digits in your second value you can use
(\d+) \s+ - \s+ ([^\d]*)
Works with your example anyway.
Dustin's didn't work for me, maybe I'm using different RegexOptions ...
|
|
|
|
|
Hi,
I have seach but can't find a tutorial, which shall do the following:
I have a datagridview, which have 5 colomns - the first 4 I gets from a database. The 5. have I created as a unbound text.
In each row I will use the 5. column to make a calculation on column 1 and 4 where I shall say: column4 = column1 * column4
In a textbox below the datagridview, I then will have that adds all the data in column5
Example:
Column1.......Column2.....Column3......Column4......Column5
QTY...........Some text...Some text....Rate.........QTY*Rate
5.............aaa.........aaaa.........100..........500,00
2.............bbb.........bbbb.........150..........300,00
Textbox which contains the totally of Column5 = 800,00
Can anybody help me with a tutorial which contains these things?
Kind regards,
simsen
|
|
|
|
|
I try to explain me in another way;
First, I make a mistake, not to say, I'm only familar with C#. Second, I don't know where to put the code - on which event it should occour.
So I don't make the mistake again... I am using VS 2005. It's a Windows Form and I have added a new column on the datagridview.
I need a function that calculates each row in the datagrid and shows the result on each row in the column I added and a function which calculates the column I have added and shows it in a textbox.
Kind regards,
simsen
|
|
|
|
|
I don't know if this will fully help but an excellent datagrid tutorial is on the CodeProject and written in 4 parts by Pete2004. Search for that, or for, "A Practical Guild to .NET DataTables, DataSets and DataGrids".
|
|
|
|
|
I any should have the same question.
The solution is:
// Databinding for the Grid
da2 = new OleDbDataAdapter("SELECT Ordre.Antal, Ordre.VareNr, Produkter.Varenavn, Produkter.PrisExMoms FROM Produkter INNER JOIN (Faktura INNER JOIN Ordre ON Faktura.FakturaID = Ordre.FakturaNr) ON Produkter.VareNr = Ordre.VareNr WHERE FakturaID=@fakid", cn);
da2.SelectCommand.Parameters.Add("@fakid", OleDbType.Integer);
da2.SelectCommand.Parameters["@fakid"].Value = fakid;
//create datatable
dtOrdrelinier = new DataTable();
//fill datatable
da2.Fill(dtOrdrelinier);
//create colum to hold the sum of other two colums
DataColumn col = new DataColumn("RaekkeBeloeb");
col.DataType = typeof(System.Decimal);
col.Expression = "Antal*PrisExMoms";
//add the colums
dtOrdrelinier.Columns.Add(col);
//Get the sum of the all totals
txtBelob.Text = dtOrdrelinier.Compute("Sum(RaekkeBeloeb)", "").ToString();
//bind datatable to grid view
dgrOrdre.DataSource = dtOrdrelinier;
|
|
|
|
|
my problem is that when I create a report (or a crystal report) rendering takes a huge amount of time (I have 30 000+ pages in this report after I use print preview)
Can I get any suggestions of how to overcome this problem?
Is this possible?
drinking beer is fun
|
|
|
|
|
30,000 is a large number. Most games try to acheive at least 30fps and old ones on modern machines achieve over 100fps.
Besides, real-time is much faster than one second.
Real Answer: If you want a real-time report make it smaller so the real-time use can use it. No one can use a 30,000 page report faster than it can be displayed.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Typically when building out a large amount of data like that, the time is not spent rendering data, but getting the entire shooting match in one shot.
An alternative (outside of Crystal Reports) would be to limit your display to a set number of rows and then handling the paging yourself. So the page forward would request items(currentHigh) to items(nextHigh) and page back would request items(nextLow) to items(currentLow).
You could tie things together by having the report generation occur in a separate thread so that as you display page 1, it is loading 2-1000 while the user decides to go to page 2, then on and on until the thread is done creating the data.
It will definitely increase the perception of speed while doing the same task.
|
|
|
|
|
i am doing a windows desktop application in C#.
In this project when I select a folder i want to traverse through its subfolders and files to the leaf level. How can i do this in C#.
I am selecting folder using FolderBrowserDialog.
I am stuck after that.. how can i gets its fils and subfolders.
I VB 6.0 and all we have files sytem and folder objects to travese. Here what we have to do?
hope i will get a reply soon
...thanks
...hari
|
|
|
|
|
Use the DirectoryInfo class.
DirectoryInfo di = new DirectoryInfo(path);
FileSystemInfo[] fi = di.GetFileSystemInfos();
fi contains a list of all the folders and files in the directory represented by path. Now you can traverse through that list. Consult MSDN on DirectoryInfo class for further details
-------------
The primary aim of AI is to make programming languages understand how frustrating it is to program them
|
|
|
|
|
The FolderBrowserDialog.SelectedPath property contains the Path selected by the user. Everything else you need can be found in the System.IO namespace in particular Directory , DirectoryInfo , File and FileInfo classes.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thanks
It worked for me
|
|
|
|
|
Hello guyz,
I am using Enterprise Library 2.0 and trying to do logging in database. What I have found is that if I use a database where I have integrated security on I can use my database listener to use database for logging but when i use Integrated Security = false with user id = sa and password = abs then Enterprise Library doesnt do any logging in database.
I must use user from database e.g "sa" I am not suppose to use integrated security.
Any idea how can I do it?
Thanks in advance.
|
|
|
|
|
Perhaps its just a lack of my knowledge of C#, which is why I am asking here for potential solutions. Thanks ahead of time for trying to help me out here.
I have a custom attribute class that is used in conjunction with my PropertyGrid, where the data is being populated from an XML file. All of this works fine and the data shows up in the PropertyGrid as expected, but all the data is marked in bold (meaning its different then its default value). Now, to set a default value in a custom attribute you use:
[DefaultValue(false)]
The only problem, is that because the default value is based off of what's in the XML file, I obviously cannot set it, due to it not being a constant. I need to be able to set the default values in the attribute class with the data that's loaded from the file.
Anyone have any suggestions on how to go about that?
Thanks,
Jacob
|
|
|
|
|
Quite a while ago I wanted to have my property grid dynamically change the the ability to see and edit data based on security in the Active Directory tree. A year later we had an awesome product, but I was deeper into the property grid then I'd ever want to be.
Bottom line: Everything in the grid is driven by attributes...and there is no way to directly change an attribute. So you must do alot of object binding to catch the calls for the attribute value and do your own determination. It is a long and (sometimes) frustrating process that is not the most flexible. If you want to persue this, then first search the forum for my user name going back the past 3 years. You should find many discussions on property grid info there. Also you will find alot of info here[^] and here.[^]
|
|
|
|
|
I went through your example and even tried bringing your code into what I was doing. Great functionality by the way, easy to use. However, when I set the default value on the property, it still displays the data in bold on the property grid.
Might it be something else?
Thank you,
Jacob
-- modified at 16:27 Wednesday 26th July, 2006
Ignore this. It was my error. Thanks a ton for your assistance.
Jacob
|
|
|
|
|
Hello
I asume what you whant to do is not possible, but I think its good as it is.
Otherwise you would have to initialize your Class Properties also dynamical (Or are you doing that?)
I think the sence of DefaultValue is that there you decrease your designer generated code.
If you change DefaultValue of a property dynamic and your initialized class variable stayes the same, your classes behavior could change in a way you don't whant.
Hope that makes sence,
All the best,
Martin
|
|
|
|
|
// When a program often has to try keys that turn out not to
// be in the dictionary, TryGetValue can be a more efficient
// way to retrieve values.
string value = "";
if (openWith.TryGetValue("tif", out value))
{Console.WriteLine("For key = \"tif\", value = {0}.", value);}
else
{Console.WriteLine("Key = \"tif\" is not found.");}
What is value? value of the dictionary i.e. in this case openWith.value?
|
|
|
|
|
This method has to return two things: a boolean indicating if the key is valid and the value associated with a key. You know that a function can only return one thing. So it uses an out parameter to return the value. So the TryGetValue method returns true if the key exists or false if the key does not exist. If the key exists, then the variable value will be set to the string associated with that key.
Logifusion[^]
|
|
|
|
|
Can a Hashtable accept two key values that are the same? if yes, then why can't a dictioanary accept two key values that are the same as it inherits from the hashtable class?
|
|
|
|