|
The consumers work with the child objects by themselves; the library is setup with delegates passed in by the consumer. There are some "generic" (not in the programming sense, but just the "here ya go" basic implementation kind of a sense) methods that could be written as actual generics or just enforce Object as the type, but the average consumer assembly for this library will be much too complicated to make use of them.
|
|
|
|
|
I'm pretty sure you'll need to go generic, and the sooner the better.
|
|
|
|
|
Here are the proposed solutions, from here and another forum:
1. Have Child implement an interface, IChildItem, and make Parent's dictionary be <string, ichilditem=""> instead.
2. Wrap the dictionary in a set of generic methods in the Parent class
3. Generic Extension methods to the dictionary
modified on Sunday, August 15, 2010 2:56 PM
|
|
|
|
|
I am creating a user control which will work as a Telephone number validator.
I want that when Regex is not a match the Text property should not return any kind of string. Can someone help with the code, as with my code, the errorprovider is instantiated but it still continues and returns the invalid phone number
public override string Text
{
get {
string phone = textBox1.Text.Trim() + textBox2.Text.Trim() + textBox3.Text.Trim();
if (!Regex.IsMatch(phone, @"^\d{9}$"))
{
errorProvider1.SetError(textBox3, "Please provide a valid phone number");
errorProvider1.SetIconAlignment(textBox3, ErrorIconAlignment.MiddleRight);
}
return phone;
}
set {
string phone;
phone = value;
textBox1.Text = phone.Substring(0, 3);
textBox2.Text = phone.Substring(3, 3);
textBox3.Text = phone.Substring(6);
}
}
|
|
|
|
|
how about putting a
return string.Empty;
inside the if-rejected?
BTW: Textbox.Text typically doesn't return null, when it is empty it gives an empty string. So I don't think bad content should return null; you could make it throw an exception though.
|
|
|
|
|
I agree with Luc that a property get should not return a null, but just as a suggestion have you considered using a MaskedTextBox instead of the three textboxes - it would probably be more obvious and friendly for the user. It would also remove the need for a regex check at all.
You can turn off the underline prompt with MaskedTextBox.PromptChar = " ";
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I did try the Masked the text box, with the
MaskedTextBox.PromptChar = " " option
but the problem was the two brackets in the text box for the phone area code( ) were too ugly and wrinkly. And also when you click on the text box the cursor is not inside the "( )" brackets it gets placed before the first bracket, which was kind of irritating. So I though let me try out the UserControl text box option. Which is working fine now.
|
|
|
|
|
Hello,
I need to find a specific mail message in outlook according it's subject. I want the program to search the mail in all the folders (including in personal folders and all sub-folders) . How can i do it?
I wrote this thing:
Outlook.Application oApp = new Outlook.Application();
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
oNS.Logon(Missing.Value, Missing.Value, false, true);
Outlook.MAPIFolder oIFolder = oNS.Folders.GetFirst();
Console.WriteLine(oIFolder.Name);
int nFolderCount = oNS.Folders.Count;
for (int p=1; p<=FolderCount; p++)
{
if(oIFolder[p].Name=="name")
return true;
}
}
The thing is that it checks only the folder name and also it is not working recursively and i don't know how to do it.
Any help?
|
|
|
|
|
i need to know that how to connect database using odbc driver
|
|
|
|
|
since you did not specify the DB server I'm pretty sure you'll find it at ConnectionStrings
I bug
|
|
|
|
|
|
Hey,
I'm trying to write into XML file,
but i've trouble to create the file
XmlTextWriter textWriter = new XmlTextWriter("C:\\testFile.xml", null);
and the exception i get is : Access to the path 'C:\testFile.xml' is denied.
what might be the problem ?
p.s
i don't have such a file in my machine
thanks
edit
OK, now i tried to write like this
XmlTextWriter textWriter = new XmlTextWriter("testFile.xml", null);
and it did work, the file was created under bin directory, but when i'm trying to write into external directory, it doesn't work... any idea why ? (maybe windows blocks any attempt to write in C drive ?)
|
|
|
|
|
This is the permission issue to the folder you want to write.
The C:\ is not permissible to write the xml file for you.
private void SetAccess(string idName, path)
{
DirectoryInfo dinfo = new DirectoryInfo(path);
FileSystemAccessRule rule = new FileSystemAccessRule(idName, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.NoPropagateInherit, AccessControlType.Allow);
DirectorySecurity dSecInfo = (DirectorySecurity)this.secInfo;
dSecInfo.RemoveAccessRule(rule);
dInfo.SetAccessControl(dSecInfo);
}
Just call the method using
SetAccess("Everyone", path)
the folder will be accessible to everyone.
Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution. Visit My Website-->www.abhisheksur.com
|
|
|
|
|
|
Right, newer versions of Windows don't let you write to the root of the system drive.
|
|
|
|
|
my question is that
is there any method in C# by which we can highlight the row of access database after certain action ??
if not
then either we can highlight the row in datagrid ??
plzzzzz reply soon
|
|
|
|
|
Look for a background color property associated with the row in your datagrid. I haven't used it yet, but most objects include that property. If it's there, you can change it in your app.
Will Rogers never met me.
|
|
|
|
|
there are several ways to control the formatting of a cell, a row, a column, in a DataGridView.
Look for DefaultCellStyle in each of those, and/or use the DataGridView.CellFormatting event.
Warning: background coloring may malfunction on empty cells; you might read my CP Vanity[^] article.
|
|
|
|
|
Good Day All
i have Successfully binded the Telerik Schedular from Objects and its looking Good. Now i have to Bind the same results but in hierachial form. Please note that i am using Telerik Grid and the implementation is the same as asp.net Gridview. i need someone to Guide me to do a hierachy grid from objects , please if you send an example code , add comments so that i can understand the logic.
private void BindViewer()
{
VS.ViewerService obj = new VS.ViewerService();
String SessionKey = obj.newSession();
DateTime Date1 = Convert.ToDateTime("1980-01-01");
DateTime Date2 = Convert.ToDateTime("2012-12-31");
VS.extract extract = obj.getObjects(SessionKey, "Butt", Date1, false, Date2, false, "", "");
try
{
RadPanelBar1.Items.Clear();
RadScheduler1.Appointments.Clear();
int Len = extract.set.Length;
for (int i = 0; i < Len; i++)
{
VS.vertex value = extract.set[i];
String PanelClass = value.meta;
PanelClass = PanelClass.Replace(Remstr, "");
PanelClass = PanelClass.Replace(Remstr2, "");
Appointment app = null;
if (value.atom != null)
{
RadPanelItem pane = RadPanelBar1.Items.FindItemByText(PanelClass);
if (pane == null)
{
RadPanelItem nwpane = new Telerik.Web.UI.RadPanelItem(PanelClass);
RadPanelItem nwpaneSpliter = new Telerik.Web.UI.RadPanelItem(PanelClass);
nwpaneSpliter.IsSeparator = true;
RadPanelBar1.Items.Add(nwpane);
pane = nwpane;
}
if (value.meta == "za.co.abacus.C_EVENT")
{
app = new Appointment();
}
int atomLen = value.atom.Length;
for (int j = 0; j < atomLen; j++)
{
VS.atom atm = value.atom[j];
if (atm.meta.Contains("za.co.reactor.A_LABEL"))
{
RadPanelItem NewItem = new RadPanelItem(atm.content);
pane.Items.Add(NewItem);
if (app != null)
{
app.Subject = atm.content;
app.Description = atm.content;
app.ID = value.key;
}
}
if (app != null && atm.meta.Contains("za.co.abacus.C_EVENT"))
{
app.ID = atm.content;
}
if (app != null && atm.meta.Contains("za.co.reactor.A_HORIZON"))
{
app.Start = Convert.ToDateTime(atm.content);
}
if (app != null && atm.meta.Contains("za.co.reactor.AA_HORIZON"))
{
app.End = Convert.ToDateTime(atm.content);
}
if (app != null && atm.meta.Contains("za.co.reactor.A_TEXT"))
{
app.Description = atm.content;
}
if (app != null && atm.meta.Contains("za.co.reactor.A_TEXT"))
{
app.RecurrenceRule = atm.content;
}
if (app != null && app.End > app.Start)
{
RadScheduler1.DataStartField = app.Start.ToString();
RadScheduler1.DataSubjectField = app.Subject.ToString();
RadScheduler1.DataEndField = app.End.ToString();
RadScheduler1.DataKeyField = app.ID.ToString();
RadScheduler1.SelectedView = SchedulerViewType.MonthView;
RadScheduler1.SelectedDate = app.Start;
SlidingZone1.ExpandedPaneId = "RadSlidingPane1";
}
}
}
}
}
catch (ApplicationException ex)
{
}
finally
{
obj.closeSession(SessionKey);
}
}
Now with the same results i want to bind a Hierachy Grid as it Shows in my attached image. I am using EAV that means the is no Fixed Column name, so the Binding of the Grid Should be Dynamically.
Thank you
http://www.telerik.com/ClientsFiles/211914_hierachygridview.JPG[^]
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
|
I'm just attempting to form a mind meld with your source code...
Nope, it's not working. Please go to Visual Studio menu: "Tools...Options...Source Control...Plug In selection" and enable "Vulcan SCMM" module. Oh, and don't close VS or turn your computer off!
Alternatively, post a relevant code fragment here, and save us all that mental effort.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
|
No - not going to look at that either! Try changing the "inline code" to "code block" it preserves the formatting.
Inline code:
if (dataFromClient == "listClients")<br />
{<br />
dataFromClient = "";<br />
<br />
foreach (DictionaryEntry Item in clientsList)<br />
{<br />
dataFromClient += Item.Key + "---" + ((TcpClient)Item.Value).Client.RemoteEndPoint.ToString() + "+++";<br />
}<br />
<br />
dataToClient = clNo;<br />
}<br />
Code block:
if (dataFromClient == "listClients")
{
dataFromClient = "";
foreach (DictionaryEntry Item in clientsList)
{
dataFromClient += Item.Key + "---" + ((TcpClient)Item.Value).Client.RemoteEndPoint.ToString() + "+++";
}
dataToClient = clNo;
} See what I mean? You can get away with it for a couple of lines, but with a whole class it is way too much effort to read!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
|
I have edited the format....
Regards.
|
|
|
|