 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
hello People,
Need your help in understanding .NET better. I know some basic stuff. problem is whenever I learn something new I dont remember it after few days. how can I implement these concepts so that I can memorize them better.
TIA
|
|
|
|
 |
Practice, practice, practice. It's the only way.
|
|
|
|
 |
Google is your friend. Reviewing old code for a technique or snippet is valuable. I stopped trying to memorize this crap years ago.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
 |
Get a book, and go through it cover to cover, doing all the exercises.
Then do them again.
After that, it's practice: there is no short cut - you remember best what you use, so if you don't use it you will lose it!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
 |
OriginalGriff wrote: so if you don't use it you will lose it
so true, especially as you get older. Knowing that you have done a thing before and forgetting where you used it is endlessly frustrating.
Never underestimate the power of human stupidity
RAH
|
|
|
|
 |
Dear friends,
I've developed an application which can convert text to speech.Now I want to control the speed of text spoken by computer i.e. customizing the speed of text. Please help how can I do this.
|
|
|
|
 |
Member 12297353 wrote: Please help how can I do this. Well, you could start off by telling us what you have used for your TTS solution. There are many different libraries that offer this and we would just be guessing what you have used.
This space for rent
|
|
|
|
 |
Dear Pete O'Hanlon,
I have used system.speech.synthesis library for my TTS application and now I want to change the duration of my speech,slow or fast as per our requirement.
For example,there will be a word "breath". I want my application to speak this word in 5 seconds and in 20 seconds too.
Please Help.
|
|
|
|
 |
This library has a Rate property - you'll have to adjust that. I will say that you aren't going to be able to get it to go to 20 seconds with a single short word.
This space for rent
|
|
|
|
 |
That all depends on what library you're using for the text-to-speech functionality. You may not have that ability at all.
But, since we have no idea what you used and what your code looks like, it's impossible for anyone to tell you.
|
|
|
|
 |
I want to convert the code List<TestGridImage> list = new List<TestGridImage>() below from Net4.0 to .Net 2.0. Can you help me ?
namespace ExampleConvertList
{
public partial class Form1 : Form
{
private List<TestGridImage> list;
public Form1()
{
InitializeComponent();
list = new List<TestGridImage>()
{
new TestGridImage() { KeyIndex = 0, KeyIndexAlt = 2 },
new TestGridImage() { KeyIndex = 1, KeyIndexAlt = 0 },
new TestGridImage() { KeyIndex = 2, KeyIndexAlt = 1 }
};
this.gridControl1.DataSource = list;
}
}
public class TestGridImage
{
private int keyIndex;
private int keyIndexAlt;
public int KeyIndex
{
get { return keyIndex; }
set { keyIndex = value; }
}
public int KeyIndexAlt
{
get { return keyIndexAlt; }
set { keyIndexAlt = value; }
}
}
}
modified 22hrs ago.
|
|
|
|
 |
Something like this should do the trickpublic Form1()
{
InitializeComponent();
list = new List<TestGridImage>();
AddToGrid(0, 2);
AddToGrid(1, 0);
AddToGrid(2, 1);
}
private void AddToGrid(int index, in alt)
{
TestGridImage image = new TestGridImage();
image.KeyIndex = index;
image.KeyIndexAlt = alt;
list.Add(image);
}
This space for rent
|
|
|
|
 |
.NET 2 didn't understand that syntax for new object creation: you either need to use a constructor (if one exists) or set the property after it is created:
list = new List<TestGridImage>();
TestGridImage t;
t = new TestGridImage();
t.KeyIndex = 0;
t.KeyIndexAlt = 2;
list.Add(t);
t = new TestGridImage();
t.KeyIndex = 1;
t.KeyIndexAlt = 0;
list.Add(t);
t = new TestGridImage();
t.KeyIndex = 2;
t.KeyIndexAlt = 1;
list.Add(t);
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
 |
The firstly thank you for just help me, I also encountered one more issue, which is the order of List<...> column. when I assign this.gridControl1.DataSource = list; list column order does not appear like that, I want to change the order of the column list what I have to edit ?
|
|
|
|
 |
I have built a class library using VS 2013 C#. It includes an interface to expose all the functions and public properties. It compiles and registers for use as COM visible. I can readily access the functions in the library from VBA. But there seems to be no way to access public properties in the class library with VBA. All the information I find on the web is for simple applications where there are no public properties, only functions. My efforts suggest that accessing public properties in the library is not doable. Is my conclusion correct? If there is a way to achieve it, maybe someone can point me to a resource.
|
|
|
|
 |
Might not be quite what you're after, but couldn't you expose the properties by means of (explicit) getter and setter functions?
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
 |
Thanks, Peter. I was hoping to avoid having to add/modify the classes that are built for .Net use with methods and properties. But I have not found any other way to approach it other than the one you suggested. On another tack, is there any software to generate an interface from the methods and properties in a class? I use copy/paste/edit which is time consuming. But I do have lots of time. Microsoft has made it difficult to use .Net with VBA, going in either direction. And it's maddening to try to hook to an open Excel workbook from a .Net application. So I gave this up.
|
|
|
|
 |
With regard to "another tack", I don't know of anything, but then I am merely a tourist in the .NET and C# district. Maybe some of the friendly locals might know.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
 |
Anyone has an AI in c# app
Felix Fernandez
|
|
|
|
 |
Did you want to ask a question or just beg for someone else to give you their hard work?
|
|
|
|
 |
Yes. Someone has. Why?
This space for rent
|
|
|
|
 |
All my programs are "intelligent" (I don't write "dumb" programs ... if I can help it).
All my programs are "artificial"; i.e. "I" made them.
So, you need to be more specific.
|
|
|
|
 |
Hi. What I'm trying to accomplish is to call this class, pass some controls and values and then have the new object update the existing control.
Help with this would be appreciated? Maybe it is not possible since I cannot pass the handle value to the class?
The error is a little misleading as the control is already created?
private void btnGroupsForUserTest_Click(object sender, EventArgs e)
{
progressBarControl pbarcontrol = new progressBarControl();
pbarcontrol.pbarIncrementValue = 1;
pbarcontrol.pbarMaximum = 100;
pbarcontrol.pbarThreadSleepIncrement = 250;
pbarcontrol.pbarObject = pBarGroupsForUser;
pbarcontrol.pbarLabel = lblGroupsForUserStatus;
progressBarIncrementer = new Thread(new ThreadStart(pbarcontrol.pbarIncrementFunction));
progressBarIncrementer.IsBackground = true;
progressBarIncrementer.Start();
}
public class progressBarControl : FormGroupMemberShipCheckingTool
{
public ProgressBar pbarObject; public Label pbarLabel;
public int pbarMaximum { get; set; }
public int pbarIncrementValue { get; set; }
public int pbarThreadSleepIncrement { get; set; }
public void pbarIncrementFunction()
{
int incrementValue = pbarIncrementValue;
do
{
this.Invoke((MethodInvoker)delegate()
{
if (incrementValue < pbarMaximum)
{
pbarObject.Value = incrementValue;
pbarLabel.Text = incrementValue.ToString() + "% complete";
Application.DoEvents();
}
});
incrementValue++;
Thread.Sleep(pbarThreadSleepIncrement);
} while (incrementValue < pbarMaximum);
}
}
|
|
|
|
 |
The progressBarControl control has been created, but the window handle for the control has not. You create a new instance of the control, but never show it anywhere, so it never creates a window.
Try using pbarObject.Invoke instead.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
Doh!
Thank you, that worked!
|
|
|
|
 |
I am getting "1.not.found.as.a.resource "error
When I am compiling the code from xcode with iphone attached, it is working fine but when I send the build to client over TestFlight it is giving me error and the PDF is not generating.
Thanks
|
|
|
|
 |
At a guess, you are doing something wrong. But without more information it is impossible to guess what.
|
|
|
|
 |
First of all my apologies if this is in the wrong forum, i'm sure i will find out very quickly if it is
So basically i am writing an API that needs to return the running date and time of tours including the offset, this format "2016-12-05T10:00:00+02:00", these tours can be in England or Italy so they run in two different timezones and should have a different offset.
Our API and DB run on servers in the US, all the running times are stored in the db as a datetime, without any offset, without anything to distinguish the timezones they run in bar the fact they are linked to different countries.
I'm just wondering what the coorect process is here, i have spent ages reading up on this and i think I'm more confused than when i started.
I am thinking that maybe i need to get the running date as a universal datetime and decrease this datetime for the English tours but i'm not sure how i can update the date to have a different offset, how to set/change the date so it knows its in a different timezone.
Any guidance, advice or suggestions of an appropriate blog/article to put me on the correct track would really be appreciated, thanks very much in advance.
|
|
|
|
 |
IMO, you are mixing two issues, one being the storage of the time and the other being the display.
Dates and times should always be stored using a common base (e.g. UTC). The exact base is irrelevant (it could just as easily be Eastern Standard Time), but it should be consistent.
The display may depend on the location of the user (e.g. all the DB users are in the U.S.), the location of the tour (display in UK time or Italian time), etc. For example, airline schedules are always displayed using the local time at the origin (for takeoff) and at the destination (for landing).
I hope this helps.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
 |
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
 |
Daniel Pfeffer wrote: Dates and times should always be stored using a common base (e.g. UTC). The exact base is irrelevant (it could just as easily be Eastern Standard Time), but it should be consistent. Spot on!
/ravi
|
|
|
|
 |
Thanks for your reply, much appreciated.
So based on your logic could I not say that all my times are stored in Italian time but not in UTC, then try to convert them to UTC and back to the English time just for the tours in England?
|
|
|
|
 |
Yes, that would work.
The advantage of using UTC for everything is that you don't need to handle switches between Daylight Saving Time and Standard Time - UTC has no Daylight Saving time. It also simplifies your code - all display times require one (and only one) conversion. Compare and contrast to the Italian --> UK case.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
 |
Im working on an Online Survey Form and a Question Builder.
You create different of question groups via the Question Builder by dragging(drag N drop) In Yes/No-questions, OptionLists and Text-input-fields. Here Is how the Question-builder looks like:(picture):
http://i.stack.imgur.com/U1RY2.png[^]
After you have created this groups with Questions, you can populate the Survey form with this Question groups. After you have created the Survey Form and added the groups of questions, the form should be assigned to all the users In the system.
I want your input on my Data-model how this should work. Below you can see my models. The thing I am a little worried about Is how the Answer-model should work.
QuestionContainer
---------------
public int ID { get; set; }
public string QuestionerContainerName { get; set; }
public virtual List<Question> Questions { get; set; }
Question
--------------
public int ID { get; set; }
public string QuestionHeader { get; set; }
public string QuestionHelpText { get; set; }
public string QuestionText { get; set; }
public virtual List<QuestionOption> QuestionOptions { get; set; }
QuestionOption
---------------
public string OptionText { get; set; }
public int RiskScore { get; set; }
public Question NestedQuestion {get; set;}
The QuestionOption Is the different of answer options/alternatives a question has.
Here comes the models for the Form Suvey
FormModel
-----------------
public int ID { get; set; }
public string Name { get; set; }
public string IntroTitle { get; set; }
public string IntroText { get; set; }
public string SupportName { get; set; }
public string SupportPhone { get; set; }
public virtual FormSection FormSections { get; set; }
FormSection
----------------------
public LicenseHolderModel LicenseHolder { get; set; }
public List<GasStationModel> GasStations { get; set; }
public List<Question> FormQuestions1 { get; set; }
public List<Question> FormQuestions2 { get; set; }
SurveyAnswers(Is this Ok??)
-----------------------
public int ID {get; set}
public int SurveyFormId {get; set;}
public int QuestionOptionId {get; set;}
public string Answer {get; set;}
Can you guys give me som Input of this? Have I missed something? As I said, Im not sure If I have got the Answer-model right. I want to store the answer on each question that the user has enterd In the form.
modified yesterday.
|
|
|
|
 |
You should create a "picture" of your model (e.g. an (ERD) Entity-Relation Diagram); this can help you "visualize" your model and identify inconsistencies: e.g.
[Question Container]->>[Question]->>[Question Option]
etc.
Based on the above:
1) Why is "Form Section" separate from "Form model" (it looks like a "0ne-for-one")
2) Missing primary key: "Question Option"
...
|
|
|
|
 |
FormSection can be In FormModel. Yeah, I have skipped the primary keys when I wrote here.
But I just want the overall input of this.
|
|
|
|
 |
I have a Dynamic asp Gridview with all columns as template feild TextBox. The columns of the Gridview are also dynamic and column count may vary everytime.
Please find code below
public void FillPoDetails()
{
DataTable dt = new DataTable();
dt = pmdata.createdatatable(int.Parse(Session["OurStyleid"].ToString()), int.Parse(Session["PoPackid"].ToString()));
GenerateTable(dt.Columns.Count, dt.Rows.Count,dt);
foreach (DataColumn col in dt.Columns)
{
TemplateField bfield = new TemplateField();
bfield.HeaderTemplate = new ArtWebApp.Controls.GridViewTemplate(ListItemType.Header, col.ColumnName);
bfield.ItemTemplate = new ArtWebApp.Controls.GridViewTemplate(ListItemType.Item, col.ColumnName);
GrdDynamic.Columns.Add(bfield);
}
GrdDynamic.DataSource = dt;
GrdDynamic.DataBind();
}
public GridViewTemplate(ListItemType type, string colname)
{
_templateType = type;
_columnName = colname;
}
void ITemplate.InstantiateIn(System.Web.UI.Control container)
{
switch (_templateType)
{
case ListItemType.Header:
Label lbl = new Label(); lbl.Text = _columnName;
lbl.CssClass = "Headerclass";
container.Controls.Add(lbl); break;
case ListItemType.Item:
TextBox tb1 = new TextBox(); tb1.DataBinding += new EventHandler(tb1_DataBinding); tb1.Columns =6; tb1.Width = 100;
tb1.Wrap = true;
tb1.ID = "txt_" + _columnName;
if(_columnName== "ColorTotal")
{
tb1.CssClass = "ColorTotal";
}
else if (_columnName == "Color")
{
tb1.CssClass = "Color";
}
else
{
tb1.CssClass = "txtCalQty";
tb1.Attributes.Add("onkeypress", "return isNumberKey(event,this)");
tb1.Attributes.Add("onkeyup", "sumofQty(this)");
}
container.Controls.Add(tb1);
break;
}
}
And inorder to get the row total I had added a Javascript function on keydown event and its working clearly
function sumofQty(objText) {
var cell = objText.parentNode;
var row = cell.parentNode;
var sum = 0;
var textboxs = row.getElementsByClassName("txtCalQty");
for (var i = 0; i < textboxs.length; i++)
{
sum += parseFloat(textboxs[i].value);
}
var textboxtotalqtys = row.getElementsByClassName("ColorTotal");
textboxtotalqtys[0].value = sum.toString();
}
can anyone please help me in finding out the sum of each columns(all same cssclass).and display it in the Sizetotal row because I am not able to loop through columns
|
|
|
|
 |
Your post title tells you that this really isn't the right forum. Why not ask in the JavaScript or Web Development forums?
This space for rent
|
|
|
|
 |
Message Removed
modified yesterday.
|
|
|
|
 |
HI,
I want to ask that,What is delegate with event?What it's use?And why we have to use it???
Can anyone explain me this concept with simple example???
Thanks...
|
|
|
|
 |
Ah, delegates and events. On the surface, they appear to be an incredibly simple concept but there are many sources of confusion on this topic. Jon Skeet published a very good explanation of events and delegates here[^]. I heartily recommend studying this article.
This space for rent
|
|
|
|
 |
Thanks for the reply, actually even i wanted to dig deep into this topic.
|
|
|
|
 |
My app has a FileSystemWatcher. Once a file is dropped into the target folder it is then Ftp'd to the server. I'm trying to make it async but I'm getting errors. I want to make the method async so that multiple files can be uploaded without blocking.
class Program
{
private static string _address;
private static string _userName;
private static string _password;
static void Main(string[] args)
{
}
public static async void FileReceived(string fileName)
{
Task<string> t = await Task.Run(() => FTPFile(fileName)); await t.ContinueWith((t1) =>
{
FileUploaded(t1.Result);
});
}
private static string FTPFile(string fileName)
{
string remoteFile = Path.GetFileName(fileName);
SFTP sftp = new SFTP(_address, _userName, _password);
sftp.UploadFileAsync(fileName, remoteFile);
return fileName;
}
private static async void FileUploaded(string fileName)
{
}
}
On the Task line I get the error:
Cannot implicitly convert type 'string' to 'System.Threading.Tasks.Task<string>'
I'm not sure how to fix this. Can someone help?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
 |
You should start the Task and then await it.
public static async void FileReceived(string fileName)
{
Task<string> t = Task.Run(() => FTPFile(fileName));
await t.ContinueWith((t1) =>
{
FileUploaded(t1.Result);
});
}
modified 5 days ago.
|
|
|
|
 |
Your FTPFile method returns a string. You're trying to put it in a Task of string.
This space for rent
|
|
|
|
 |
You should avoid async void methods wherever possible:
Avoid async void methods - You’ve Been Haacked[^]
Async/Await - Best Practices in Asynchronous Programming[^]
Also, sftp.UploadFileAsync implies that the method returns before the upload has completed. Does this method return a Task, or does it raise an UploadFileCompleted event? If it raises an event (EAP pattern), you can wrap that in a Task-returning method, and make your FTPFile method async as well.
How to: Wrap EAP Patterns in a Task[^]
Tasks and the Event-based Asynchronous Pattern | Parallel Programming with .NET[^]
public static class SFTPExtensions
{
public static Task UploadFileTaskAsync(this SFTP sftp, string fileName, string remoteFile)
{
var tcs = new TaskCompletionSource<bool>();
UploadFileCompletedEventHandler handler = null;
handler = (sender, args) =>
{
if (args.Cancelled)
{
tcs.TrySetCancelled();
}
else if (args.Error != null)
{
tcs.TrySetException(args.Error);
}
else
{
tcs.TrySetResult(true);
}
sftp.UploadFileCompleted -= handler;
};
sftp.UploadFileCompleted += handler;
try
{
sftp.UploadFileAsync(fileName, remoteFile);
}
catch (Exception ex)
{
sftp.UploadFileCompleted -= handler;
tcs.TrySetException(ex);
}
return tcs.Task;
}
}
public static async Task FileReceived(string fileName)
{
string result = await FTPFile(fileName).ConfigureAwait(false);
await FileUploaded(result).ConfigureAwait(false);
}
private static async Task<string> FTPFile(string fileName)
{
string remoteFile = Path.GetFileName(fileName);
SFTP sftp = new SFTP(_address, _userName, _password);
await sftp.UploadFileTaskAsync(fileName, remoteFile).ConfigureAwait(false);
return fileName;
}
private static async Task FileUploaded(string fileName)
{
...
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
 |
public partial class BlinkLabel : Label {
private CancellationTokenSource ts;
private Task task1;
public BlinkLabel()
{
InitializeComponent();
}
public void StartBlink()
{
ts=new CancellationTokenSource();
CancellationToken ct = ts.Token;
if ( isRunningTask(task1) ) return;
task1 = Task.Factory.StartNew(() =>
{
while (true)
{
ct.ThrowIfCancellationRequested();
Thread.Sleep(500);
Visible = !Visible;
}
}, ct);
blinkTask.ContinueWith(t =>
{
Visible = false;
},TaskContinuationOptions.None);
}
public void StopBlink()
{
ts.Cancel();
}
}
public partial class MainForm: Form
{
public MainForm
{
InitializeComponent();
blinkLabel1.Text="Blinking message...";
blinkLabel1.StartBlink(); blinkLabel1.StopBlink(); }
}
I have some question:
1- why cancel request doesn't work?
2- how we can debug parallel program? when i use Ctrl+F5 the program works, when use F5 invoke errors occured.
3- Does exist better way to create blinkLable user control instead Task?
please get a solution for this problem, i don't have enough experience in parallel programming. thanks/.
|
|
|
|
 |
Programmer 1 wrote: 1- why cancel request doesn't work? Dunno, but it looks like you are throwing an exception inside a new thread without handling it.
Programmer 1 wrote: 2- how we can debug parallel program? when i use Ctrl+F5 the program works, when use F5 invoke errors occured. Walkthrough: Debugging a Parallel Application[^]
Programmer 1 wrote: 3- Does exist better way to create blinkLable user control instead Task? If all you need is a blink-label, use a timer and not a thread.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|