|
So you are asking someone to write this for you?
only two letters away from being an asset
|
|
|
|
|
I am not mean to say like that....
In other site, I have posted the same question. So, He told me to discribe more.
Thanks & Regards,
Liyakhat.
|
|
|
|
|
It is better you try something and post what is your difficulty and there are many people to help you. It is doubt someone can do everything for you.
Also avoid writing mail Id to avoid spam mail.
All the best for your project!!
Best Regards,
Suman
|
|
|
|
|
liyakhat_shahid wrote: 1. CSV Input File is created by user or external application
2. My Application reads data in from CSV file
3. My Application converts records from the CSV file to a new format (xls format)
4. My Application outputs to text file.
Erm... I can do that without writing 1 line of code. Excel will happily open a CSV text file.
Or is this Homework and you just can't be bothered?
|
|
|
|
|
Hi,
I know how to id manuly, but we have to do it programatically.
thank,
Liyakhat
|
|
|
|
|
J4amieC wrote: Or is this Homework and you just can't be bothered?
liyakhat_shahid wrote: we have to do it programatically.
So the answere is, Yes I think!
All the best,
Martin
|
|
|
|
|
Hi J4amieC,
Can you please tell me how to do it programatically. Atleast send related link. I search google but I didn't find any.
Waiting for u r reply
Thanks & Regards,
Liyakhat.
|
|
|
|
|
liyakhat_shahid wrote: KeyNotFoundError
That's your problem, there is no field called "MyColumnName" in FieldValues. Make sure that you type in the correct string here.
|
|
|
|
|
hi all,
i want to make a search dialog in c#, i want to show it with ctrl+F , now i don't know how can i do it .
i mean when i press ctrl+F the dialog should appear .
please tell mehow can i do it.
Praveen Sharma
|
|
|
|
|
Hi,
in your form:
- set KeyPreview true
- install a KeyPress handler, have it check for letter 'f', if so check
CTRL key is down (use Control.ModifierKeys), if so create a new dialog form and
show it with ShowDialog; you may choose an OpenFileDialog or something you
design yourself.
That should do it.
|
|
|
|
|
thanm u very much Luc , may i know , where u from Luc????
Praveen Sharma
|
|
|
|
|
Belgium, Europe, Earth, Milky Way, Universe
|
|
|
|
|
Belgium, (that's to the west of Germany, as you well know).
|
|
|
|
|
Hi!
In addition to what Luc said, it usually is a good idea to not just offer a single way to access a certain functionality, so you could add a menu to your form, add an Edit/Find command and give it a shortcut of Ctrl+F.
That way, the user can either use the menu or the shortcut and you don't even have to care about keyboard preview on your form yourself...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi guys!
For showing context-sensitive help in one of my applications, I've created an HTML page with bookmarks for several topics.
In order to show the page, I'm simply using something like
Process.Start(pathToHtmlFile);
Unfortunately, I can't give a bookmark to jump to, because if I do, the path looks something like C:\Program Files\MyApp\AppHelp.htm#icons and therefor windows doesn't recognize the htm extension anymore
Also using file:///C:/Program Files/MyApp/AppHelp.htm#icons instead of the plain path doesn't work.
Any other ideas?
Thanks in advance.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi mav,
you could integrate a WebBrowser in your app, and order it to Navigate() wherever
you want.
|
|
|
|
|
I could, but I'd rather use the user's default browser...
In fact (and I'm a little ashamed about it) I had implemented a workaround some time ago, but while testing this app under Vista, the whole thing blew right into my face.
The idea then was to create a temporary html file containing a tiny javascript call to actually navigate to the real URL including the bookmark. This temporary file was called with Process.Start() .
After a 1 second wait I deleted the temp file. (that's the part I'm ashamed about now. The 1 second was hard-coded and isn't enough for Vista to start the browser. I even thought about posting it under WTF).
I _could_ increase the time, but it still feels like a hack.
That's why I was asking for a different way to do it, a cleaner way.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi,
if you are willing to spend the effort, here is an idea:
- find out what is the default browser; I think you could do this by using
Process.Start on any html file, then wait for idle, and look at StartInfo.
Or search the registry...
- now for each of your help items, do a Process.Start of the right browser app,
and pass the URL as the first argument. (I am hoping whatever the browser,
it always looks at its command line).
Of course, you could silently combine both methods: first time launch your
help file without bookmark (and note down the app info), later on use the above.
BTW: the WaitForIdle() is also an improvement on your earlier fixed 1 sec delay,
but I did not like your temp file much in the first place...
|
|
|
|
|
Luc Pattyn wrote: but I did not like your temp file much in the first place...
me neither...
At that time it seemed a good idea, tho (well, at least it was working...)
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi,
I've created the following function (it gets forms from a pool):
public formType GetForm<formType>(string form_id) where formType : Form
I've stored the type of form I want to get in a Type variable somewhere, for example:
Type classToGet = typeof(Form);
The Form is just an example, this normally determined dynamically.
Now when I try to call my GetForm function like this:
GetForm<classToGet>("myformid");
I get a compiler exception saying "classToGet is a type parameter but is used like variable" and that "Type or namespace classToGet could not be found".
Is there anyway of solving this problem? I suppose there's a problem involving me not understanding reflection thoroughly enough. I realize I'm passing an argument of type Type but I can't seem te get my mind around converting the Type class to the class-reference I need here.
Thanks in advance for any help!
Standards are great! Everybody should have one!
|
|
|
|
|
This behaviour is because you are trying to use a variable instead of a type. This goes against the nature of generics which identifies information about an object at compile time.
Now, to get around this you would use:
GetForm<Form>("myformid");
|
|
|
|
|
I know how to get around it. The thing is, I want to provide the type at runtime using reflection. The reason for this is that somewhere in the GetForm method there's a line saying:
formType ret = Activator.CreateInstance<formType>();
I need to call the specific constructor for the type that's provided. This is why simply passing type Form will not do. Since I can ensure the compiler that the type passed will be a descendant of Form, I figured there's enough information for it to work with.
Standards are great! Everybody should have one!
|
|
|
|
|
I don't understand why you would want to do this in this way. As I stated before, generics are really handled at compile time. I knocked up the following quick routine to get a form.
namespace GenericForms
{
public static class TestForms
{
public static Form ShowForm(string formName)
{
return (Form)Activator.CreateInstance(Type.GetType(formName));
}
}
} Calling this becomes as simple as GenericForms.TestForms.ShowForm("Form1").ShowDialog(); .
|
|
|
|
|
The thing is, I'm working in a MDI application and want to store and retrieve all of the forms that were open when the application last closed. Here's my code, maybe not so pretty, but I think you'll get it...
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Drawing;
using System.Diagnostics;
namespace Tools
{
[Serializable]
public class FormsPool
{
/// <summary>
/// This dictionary will store the form's properties that we want to save to file.
/// </summary>
private Dictionary<string, FormData> dataPool = new Dictionary<string, FormData>();
/// <summary>
/// And this one is used to store forms at runtime.
/// </summary>
[field: NonSerialized]
private Dictionary<string, Form> formPool = new Dictionary<string, Form>();
/// <summary>
/// Get the form with the specified id.
/// </summary>
/// <param name="form_id">Unique string identifying the form to get.</param>
/// <returns></returns>
public Form GetForm(string form_id)
{
return GetForm<Form>(form_id);
}
/// <summary>
/// Returns the form with the given id from the pool. If it's not there, it'll be constructed.
/// </summary>
/// <typeparam name="formType">The form class you want to be returned.</typeparam>
/// <param name="form_id">The id for the form to return.</param>
/// <returns></returns>
public formType GetForm<formType>(string form_id) where formType : Form
{
if (formPool == null) // make sure our dictionaries are there
formPool = new Dictionary<string, Form>(); // (deserialization can set them to be null)
if (dataPool == null)
dataPool = new Dictionary<string, FormData>();
if (this.formPool.ContainsKey(form_id)) // check out if we have a reference to the form
{
if (formPool[form_id] != null)
return formPool[form_id] as formType; // if so, return it
else formPool.Remove(form_id);
}
formType ret = Activator.CreateInstance<formType>(); // not there, so create it
if (dataPool.ContainsKey(form_id)) // check for past references to this form
{ // and get the data used in that case
ret.StartPosition = FormStartPosition.Manual;
ret.Size = dataPool[form_id].size;
ret.Location = dataPool[form_id].location;
this.formPool.Add(form_id, ret);
}
else // otherwise, reset all parameters
{
FormData data = new FormData();
data.type = typeof(formType);
this.dataPool.Add(form_id, data);
this.formPool.Add(form_id, ret);
}
// the form that was asked for has been newly instantiated, so we'll need to track movement and sizechanges
ret.LocationChanged += delegate(object sender, EventArgs e)
{
foreach (string key in formPool.Keys)
{
if (formPool[key].Equals(sender))
{
if (dataPool.ContainsKey(key))
{
Form form = sender as Form;
FormData data = dataPool[key];
data.location = form.Location;
dataPool[key] = data;
}
}
}
};
ret.SizeChanged += delegate(object sender, EventArgs e)
{
foreach (string key in formPool.Keys)
{
if (formPool[key].Equals(sender))
{
if (dataPool.ContainsKey(key))
{
Form form = sender as Form;
FormData data = dataPool[key];
data.size = form.Size;
dataPool[key] = data;
}
}
}
};
return ret;
}
/// <summary>
/// Save all formdata to a file. Look out, no errorhandling.
/// </summary>
/// <param name="filename">The filename to store our data in.</param>
public void Save(string filename)
{
Stream stream = File.Open(filename, FileMode.Create);
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(stream, this);
stream.Close();
}
/// <summary>
/// Return a formspool from file that was saved using the Save method.
/// </summary>
/// <param name="p"></param>
/// <returns></returns>
public static FormsPool FromFile(string filename)
{
Stream stream;
try
{
stream = File.Open(filename, FileMode.Open);
}
catch (FileNotFoundException)
{
return new FormsPool();
}
BinaryFormatter formatter = new BinaryFormatter();
FormsPool pool = null;
try
{
pool = formatter.Deserialize(stream) as FormsPool;
}
catch { }
finally
{
if (pool == null) pool = new FormsPool();
stream.Close();
}
return pool;
}
}
[Serializable]
public struct FormData
{
public Type type;
public string form_id;
public Point location;
public Size size;
}
}
Standards are great! Everybody should have one!
|
|
|
|
|
Biggest mistake :
this code :
Type classToGet = typeof(Form);
here Form is the base class of all the forms, so u cant use base class to get the type of form.
Instead if u use as argument in typeof() any derived class of base class(Form)then it will return that derived Class and base on it this code :
Type classToGet = typeof(DerivedClassOfForm);//Return Form "derived Class"
which you can during debug time it will view as GetForm<derivedclass>("myformId")
GetForm<classtoget>("myformid");
This is difficult to explain as well as to understand .For more details learn Factory Pattern from http://www.c-sharpcorner.com.
Regards
Chintan
www.visharadsoft.com
(Nothing is so purify as KNOWLEDGE)
|
|
|
|