|
I'm confused now. What does dv.Find do? Could you try out this little code snippet and tell me what it prints and if that's what you expect?
string x = "Richard Rocks";
string y = "My rich uncle";
Regex regex = new Regex(@"^Rich");
Console.WriteLine(regex.IsMatch(x));
Console.WriteLine(regex.IsMatch(y));
It should print True and False. Is that what you expect?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Ok, I did get the true and false, but it doesn't make sense (to me) why I'd have trouble below.
What my dv.Find does is get the row number in the datatable that contains "Rich" in it so that I can highlight it.
I have the code in the first post, but where the problem seems to be is:
DataView dv = tCat.DefaultView;<br />
Regex reg = new Regex(@"^Rich");<br />
int i = dv.Find(reg);
When I have "Richard" instead of @"^Rich", it highlights the row just fine.
Any other thoughts?????
Thanks again for your help,
Mel
|
|
|
|
|
You sure DataView.Find handles regexes? MSDN[^] doesn't say anything about it handling regular expressions.
Regards Senthil _____________________________ My Blog | My Articles | WinMacro
|
|
|
|
|
I've go a Custom Control that inherits from the TextBox class and I've added a ListBox; I needed to create a custom event exposed to the parent form that would fire when the ListBox changed visiblity. The code below works but I know it's now quite right. Any help appreciated.
Control Code Snippet==============================================
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
public delegate void ListBoxEvent();
namespace TextBoxLookupLib
{
///
/// Custom Textbox Control
///
public class TextBoxLookup : System.Windows.Forms.TextBox
{
private System.Windows.Forms.ListBox listBox1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public event ListBoxEvent ListBoxVisibleChanged;
public TextBoxLookup()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitComponent call
this.listBox1.Visible = false;
this.listBox1.Width = this.Width;
this.listBox1.TabStop = false;
this.DoubleClick +=new EventHandler(TextBoxLookup_DoubleClick);
this.listBox1.DoubleClick +=new EventHandler(listBox1_DoubleClick);
this.listBox1.VisibleChanged +=new EventHandler(listBox1_VisibleChanged);
ListBoxVisibleChanged += new ListBoxEvent(OnListBoxVisibleChanged);
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region Component Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.listBox1 = new System.Windows.Forms.ListBox();
//
// listBox1
//
this.listBox1.Location = new System.Drawing.Point(17, 17);
this.listBox1.Name = "listBox1";
this.listBox1.TabIndex = 0;
}
#endregion
private void OpenListBox()
{
Control ctlParent = this.Parent;
ctlParent.Controls.Add(this.listBox1);
this.listBox1.Width = this.Width;
this.listBox1.BringToFront();
this.listBox1.Visible = true;
}
private void CloseListBox()
{
this.Focus();
this.listBox1.Visible = false;
this.listBox1.SendToBack();
this.Refresh();
}
private void TextBoxLookup_DoubleClick(object sender, EventArgs e)
{
this.OpenListBox();
}
private void listBox1_DoubleClick(object sender, EventArgs e)
{
this.CloseListBox();
}
private void listBox1_VisibleChanged(object sender, EventArgs e)
{
ListBoxVisibleChanged();
}
public void OnListBoxVisibleChanged()
{
//Why this method call?
}
}
}
Form Code Snippet=============================================
this.textBoxLookup1.ListBoxVisibleChanged +=new ListBoxEvent(textBoxLookup1_ListBoxVisibleChanged);
private void textBoxLookup1_ListBoxVisibleChanged()
{
if(this.textBoxLookup1.ListSelectedValue != null)
this.textBox1.Text = this.textBoxLookup1.ListSelectedValue;
}
"She folds her legs...in doing so I glimpse Xanadu."--Gilby
|
|
|
|
|
How to save my paint on a form or a picture box ?
|
|
|
|
|
I'm having trouble finding resources related to sound recording and streaming those files. Effect I want to make is identical to Skype (or other IM) voice chat... I want to be able to capture sound using microphone, compress it, send it over wire using .NET Remoting and than, of course, play it.
However most project I've find deal with saving file to disk, or just compressing some file... So does anyone has some expirience in this field and is willing to share it?
tnx in advance
|
|
|
|
|
how to create a dll file. where, and how it is used?
|
|
|
|
|
ambedkar wrote: how to create a dll file.
Create a Class Library project
ambedkar wrote: where, and how it is used?
A DLL is, in .NET, a type of assembly that is usually a Class Library. Code behind for ASP.NET applications compile to DLL files.
It is used to hold libraries of code. For example, The business logic of an application may be put in a DLL in order to separate it from the user interface. A set of custom controls may be put in a DLL. Test fixtures are normally placed in a separate DLL from the set of classes that they test.
Basically, any code that is invoked from somewhere else.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
Is anyone has an idea how do I generate 6 digits unique number for the same day. (Based on time ?!) The number should be milliseconds difference.
10x
TD
|
|
|
|
|
Ronent wrote: how do I generate 6 digits unique number for the same day
same day as what? To what is the day in comparison?
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
A quick check of the number of milliseconds in a day gives 86400000
TimeSpan ts = new TimeSpan(1,0,0,0,0);<br />
Console.WriteLine(ts.TotalMilliseconds);
So, first point you are not going to be able to generate a unique 6 digit number, that is millisecond different, based on the current millisecond in a given day.
Lets see how accurate it could be....
Max 6 digit number = 999999
Milliseconds in a day = 86400000
Spread = 86400000 / 999999 = 86.4ms (approx)
So every 86.4ms (thats 0.086 seconds) a new number would be generated, every call to generate a number within that timespan would create the same number.
Now, your choices
1) If your app will never make a call to generate this number as frequently as every 100ms, you are free to use the above solution. Just get the current number of miiliseconds since midnight, divide by (approx - do the math) 86.4, round to the nearest integer and you will have a 6 digit whole number.
2) If you DO actually need this accurate within 1ms (which i doubt) you can use a bigger number (Milliseconds is usually depicted as an int).
|
|
|
|
|
10x a lot
I guess that's very close to what I need
|
|
|
|
|
J4amieC hi,
I used your idea and by using Hexadecimal format,
I succeed to reduce it to 8 milisecond.
decimal i = (decimal)(new TimeSpan(1,0,0,0,0).TotalMilliseconds / 9999999);
DateTime d = DateTime.Now;
TimeSpan timeSpan = d.Subtract(new DateTime(d.Year, d.Month, d.Day));
double ml = timeSpan.TotalMilliseconds;
int ii = (int)((decimal)ml / i);
Console.WriteLine("ii=" + ii.ToString("X"));
10x
TD
|
|
|
|
|
You've done your math backwards. with 86.4M values generated/day and a need for only 1M values needed/day, you've got ~86 potential values for each needed one. .net timers aren't accurate to single ms values though, I saw (but don't recall where) a comparison chart of timing methods, which ranged from ~10-50ms precision.
|
|
|
|
|
The simple way to work this is to store the last number given and 'lie' a bit if the requests for numbers come too frequently:
x = timeInMS/100;
if( x== last )
++x;
last = x;
This gaurantees uniqueness but will occasionally give the wrong time in circumstances that cannot be avoided
Note that if the ++x is common then want you want is impossible anyway.
P.S. I haven't used hex encoding in this but why stop at base16? Use base64 and get greater precision
|
|
|
|
|
As in subject.
Thanks in advance.
Regards,
Nish
|
|
|
|
|
Yes, if the VC# compiler is to be believed. This code compiles fine on my machine
[assembly:CLSCompliant(true)]
namespace ConsoleApplication1
{
[CLSCompliantAttribute(true)]
public class Program
{
public void Method(params object[] x)
{
}
static void Main(string[] args) { }
}
}
[EDIT]
Brad Abrams[^] has this to say when discussing params ,
"Do not use the VarArgs calling convention, otherwise known as the ellipsis (…), exclusively because the Common Language Specification does not support it[3]."
So yes, params is CLS compliant. Interestingly, the params keyword simply seems to make the C# compiler wrap the arguments in an object array and pass it to the callee. In fact, the params thing just seems to generate an attribute for that parameter in IL, probably for use in reflection.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
-- modified at 7:44 Tuesday 6th December, 2005
|
|
|
|
|
Thanks Senthil.
S. Senthil Kumar wrote: Interestingly, the params keyword simply seems to make the C# compiler wrap the arguments in an object array and pass it to the callee. In fact, the params thing just seems to generate an attribute for that parameter in IL, probably for use in reflection.
Yep, that's what prompted my question. It's not directly supported in IL, and is implemented using a custom attribute on the parameter. And the calling code is always converted to using an array.
|
|
|
|
|
Hi to everybody.
My problem is simple how to make some label to be refresh every second?
bye best regards
|
|
|
|
|
papa1980 wrote: My problem is simple how to make some label to be refresh every second?
If this is a win forms application then you can drop a timer on to the form and create an event handler for its, if I remember, Tick event. In your tick event handler you can update the label.
If this is for a web application you would need some javascript to do this.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
|
but how to call to this timer???
|
|
|
|
|
|
I find it and make it but i don't know why when i refresh my screen is view some black line it is not look well how i can repair it???
|
|
|
|
|
papa1980 wrote: I find it and make it but i don't know why when i refresh my screen is view some black line it is not look well how i can repair it???
Thats a new one on me. I've never heard of that happening. Remember that the timer component is a non-visual component, so it won't show up on your form. Instead it will show up on your form designer in a separate area underneath the form - this will not affect how the form is displayed.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|