|
Just one question.
I was assuming that ItemManager was a built in class, but as I can't find it, I'm now assuming that you meant I should make an Item manager myself. Other than that, I'm planning on trying that out sometime today.
- Munty
|
|
|
|
|
Muntyness wrote: I'm now assuming that you meant I should make an Item manager myself.
Yes that's correct.
I was thinking of something like that:
public class ItemManager
{
private static ItemManager _instance;
private Array _availableitems = new Array();
public ItemManager()
{
}
public Array AvailableItems
{
get
{
return _availableitems;
}
set
{
if(value!=_availableitems)
{
_availableitems = value;
}
}
}
public static ItemManager GetInstance()
{
if(_instance==null)
{
_instance = new ItemManager();
}
return _instance;
}
}
Hope that helps!
All the best,
Martin
|
|
|
|
|
Aye, that helps alot.
Thanks!
- Munty
|
|
|
|
|
Alrighty, Im here to bug you again.
So I took your framework and butchered it. (What can I say? I'm stupid )
public class fnt_ItemManager
{
public event EventHandler ArrayChanged;
private Array _availableitems;
public fnt_ItemManager()
{
}
public Array AvailableItems
{
get
{
return _availableitems;
}
set
{
if (value != _availableitems)
{
_availableitems = value;
}
}
}
public void update (String oldVal, String newVal)
{
ArrayList updating = new ArrayList();
int i = 1;
if (oldVal != null)
{
foreach (String st in _availableitems)
{
if (newVal != st || newVal == "#NONE")
{
updating.Add(st);
}
}
if (oldVal != "#NONE")
{
Boolean found = false;
while (i < updating.Count)
{
if (int.Parse((String)updating[i]) > int.Parse(oldVal))
{
updating.Insert(i, oldVal);
found = true;
break;
}
i++;
}
if (oldVal != null && found == false)
{
updating.Add(oldVal);
}
}
String[] rar = new String[updating.Count];
i = 0;
foreach (String st in updating)
{
rar[i] = st;
i++;
}
_availableitems = rar;
if (ArrayChanged != null)
{
ArrayChanged(this, EventArgs.Empty);
}
}
}
}
}
And in the control that calls it:
private void cmb1_SelectedIndexChanged(object sender, EventArgs e)
{
OldValue = Current;
Current = cmb1.Text;
if (OldValue != null && OldValue != Current)
{
ItemManager.update(OldValue, Current);
}
}
void p_ItemManager_ArrayChanged(object sender, EventArgs e)
{
cmb1.Items.Clear();
foreach (String st in p_ItemManager.AvailableItems)
{
cmb1.Items.Add(st);
}
}
Now then, this actually works for the most part, however it's kinda iffy (seems to call all the handlers in the control class twice). Plus in the combo boxes, while the code see's the values that are in the boxes, people can't. So the code would see that the box contained "5", however I'm only seeing "". Kinda iffy once again.
Sooo, is this worth keeping, or should I just scrap it all and take up farming now?
- Munty
|
|
|
|
|
Hello Munty,
Muntyness wrote: should I just scrap it all and take up farming now?
I think this would be the best solution for everyone!
My suggestions are:
UserControl:
Maybe the SelectedIndexChanged Event is raised to often because of the "Items.Clear" and "Items.Add".
So a boolen flag in the SelectedIndexChanged Method could help.
private bool updating;
private void cmbl_SelectedIndexChanged(object sender, EventArgs e)
{
if(updating==false)
{
OldValue = Current;
Current = cmb1.Text;
.
.
.
}
}
private void p_ItemManager_ArrayChanged(object sender, EventArgs e)
{
updating = true;
.
.
.
updating = false;
}
ItemManager:
Have you used the GetInstance Methode?
The update Method looks much too complicated for working correct.
Why cant't you just add and remove directly from the Array?
See you!
Martin
|
|
|
|
|
Martin# wrote: ItemManager:
Have you used the GetInstance Methode?
Admittedly no. To be honest I wasn't sure what that method was for...
Martin# wrote: Why cant't you just add and remove directly from the Array?
I can directly remove from the array (it now does that ), it's just that when I add to the array, the items need to be ordered. So I can either put the value into the correct place to start with, or I can sort the array after the item has been added. I'm fairly sure that sorting the array after every change would probably be worse, but if it's better to sort, feel free to tell me.
the code now looks more like this:
(There are 2 combo boxes now, but the methods are identical except for some names)
private void cmb1_SelectedIndexChanged(object sender, EventArgs e)
{
OldValue1 = Current1;
Current1 = cmb1.Text;
if (OldValue1 != null && OldValue1 != Current1)
{
selected = 1;
ItemManager.update(OldValue1, cmb1.SelectedIndex);
}
}
void ItemManager_ArrayChanged(object sender, EventArgs e)
{
if (selected != 1)
cmb1.Items.Clear();
if (selected != 2)
cmb2.Items.Clear();
foreach (String st in p_ItemManager.AvailableItems)
{
if (selected != 1)
cmb1.Items.Add(st);
if (selected != 2)
cmb2.Items.Add(st);
}
selected = 0;
}
int the item manager:
public class fnt_ItemManager
{
public event EventHandler ArrayChanged;
private ArrayList _availableitems = new ArrayList();
private String Default;
public fnt_ItemManager(String defaultcont)
{
Default = defaultcont;
}
public ArrayList AvailableItems
{
get
{
return _availableitems;
}
set
{
if (value != _availableitems)
{
_availableitems = value;
}
}
}
public void update(String oldVal, int index)
{
Boolean found = false;
int i = 0;
if (index != 0)
{
AvailableItems.RemoveAt(index);
}
if (oldVal != Default)
{
foreach (String st in AvailableItems)
{
if (st.CompareTo(oldVal) > 0)
{
AvailableItems.Insert(i, oldVal);
found = true;
break;
}
i++;
}
if (oldVal != null && found == false)
{
AvailableItems.Add(oldVal);
}
}
if (ArrayChanged != null)
{
ArrayChanged(this, EventArgs.Empty);
}
}
}
It's better than before, but still buggy. (Go me!
- Munty
-- modified at 9:55 Tuesday 12th December, 2006
|
|
|
|
|
Hello Munty,
Muntyness wrote: Admittedly no. To be honest I wasn't sure what that method was for.
This Method generates only one instance of the fnt_ItemManager.
It's also static, so you do not need an instance of the class to call it.
Cause if you make a instance like this:
fnt_ItemManager p_ItemManager = new fnt_ItemManager();
Every Control has its one instance of the Manager and has no idea which item is used by an other Control.
So please implement the method like i did and call it from the Controls, like that:
fnt_ItemManager p_ItemManager = yourenamespace.fnt_ItemManager.GetInstance();
If no't all controlls are linked (sharing one set of items), please let me know.
We would have to make the GetInstance method more dynamic to create and return more than one instance.
Hope that helps!
All the best,
Martin
|
|
|
|
|
So that's what it does!
Hmm... I might try that when I next have some free time with the code (Which wont be till tommorow at the earliest)
At the moment I've just created the instance in the GUI that the user controls are added too. And then whenever the user adds another control, the ItemManager instance is passed into the new user control.
So it looks something like:
(In the create control method)
UserControl something = new UserControl(ItemManager);
And in the item manager, something like:
(In the user controls class)
private theItemManager itemManager;
public UserControl (theItemManager item)
{
itemManager = item;
}
(Incase you're wondering, I don't have the code infront of me right now)
And don't worry, all the controls are using one set of items.
Thanks for all the help you're giving me by the way.
- Munty
|
|
|
|
|
hi all,
I'm using oledb connection to read a dat file into dataset.
i've converted the dat file into txt file and created schema.ini file with |delimiter. It reads fine but my prob is no of rows count in the dataset is less than in the file(just only one row). Event i mentioned the hdr = no extended properties. Plz help
here i've given the sample code
public static DataSet FileReader(string Filename, bool SchemaRequired, DataSet dsCol)
{
string newFilename = "";
string filextn = Path.GetExtension(Filename).ToUpper();
string schemafile = "";
if(filextn == ".DAT")
{
// To change the File extension if the file type is DAT
newFilename = Path.ChangeExtension(Filename,"TXT");
File.Move(Filename,newFilename);
}
else
{
newFilename = Filename;
}
if(SchemaRequired)
{
//This Schema.ini file is required to read the text file with custom delimiters here we use(|)
schemafile = Path.GetDirectoryName(Filename)+@"\Schema.ini";
if(File.Exists(schemafile))
{
File.Delete(schemafile);
}
using(StreamWriter writer = File.CreateText(schemafile))
{
writer.WriteLine("["+Path.GetFileName(newFilename)+"]");
writer.WriteLine("Format = Delimited(|)");
for(int i = 1; i<= 19; i++)
writer.WriteLine("Col"+ i +"=C"+ i + " Text");
}
}
string PathtoTextFile = Path.GetDirectoryName(newFilename);
System.Data.OleDb.OleDbConnection oConn = new
System.Data.OleDb.OleDbConnection(
"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + PathtoTextFile + ";" +
"Extended Properties=\"text;HDR=NO;FMT=Delimited\"");
System.Data.OleDb.OleDbDataAdapter oCmd = new System.Data.OleDb.OleDbDataAdapter(
"select * from "+Path.GetFileName(newFilename),oConn);
DataSet myDS = new DataSet();
try
{
oCmd.Fill(myDS);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return null;
}
finally
{
if(SchemaRequired)
File.Delete(schemafile);
if(filextn == ".DAT")
{
Filename = Path.ChangeExtension(newFilename, "DAT");
File.Move(newFilename,Filename);
}
}
return myDS;
}
|
|
|
|
|
public static void main()
{
try
{
//some exception occured
}
catch()
{
system.out.println(" ");
}
finnaly
{
system.out.println("hai");
}
system.out.println("hello");
}
is hello wud be printd or not
plz let me know asap
with regards
|
|
|
|
|
Why haven't you tried this out for yourself? You have most of the code there, so it is a simple matter for you to test it it, except for the fact that there is no System.Out.Println - that's a Java class. Change that to Console.WriteLine and put in a divide by zero error into the try block, and you will be good to go.
BTW - please don't put SMS speak into posts. This makes it harder for the person who is reading it to understand.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi
Does anybody know where the Copy Local reference property is perstisted?? I assumed it would be in the project file, but I can't seem to find the defintion.
Thanks
|
|
|
|
|
Dear all,
currently, i am developing a project where i need to display the chart which i created in Windows Form into a webpage using C#, is it possible?
Besides, is there any way to automatically update the chart base on the latest data that get from internet (use TCPIP to host to the webpage and retrieve the latest info)?
Your help is greatly appreciated.
Thank you.
Sincerely,
Velerena
|
|
|
|
|
Yes, you can very well host a windows form or windows control in a web page, for that you need to make your form as a activex control, actually u just need to use the tlbexp.exe and get the .tlb file, make sure u gice a guid attribute to your class, u have to register the tlb using regsvr32 and use it as how u ll embed a activex control in a web page , using java script.
|
|
|
|
|
Hi,
Thanks for your reply. I am a newbie in C# language, i am still doing my research on this project. My chart s display in ActiveX control. I have no idea what is tlbexp.exe and .tlb and how can i register the tlb using regisvr32? Can you please give me some guideline on this?
Thank you so much.
Sincerely,
Velerena
|
|
|
|
|
What i need to do is get a row from a nodeTag and then insert that row into a new table while editing a column value.
The code below is what i do at the moment, but it never changes the value e.g.: copiedRow[classLabel] = newValue;
DataRow row = nodeTag.OriginalRowRef;<br />
mainDataSet.Tables["Modified" + nodeTag.ClassName].ImportRow(row);<br />
<br />
DataRow[] copiedRows = mainDataSet.Tables["Modified" + nodeTag.ClassName].Select("[" + classStruct.ClassKey[0] + "] = '" + nodeTag.NodeName + "'");<br />
foreach (DataRow copiedRow in matchingRows)<br />
{<br />
if (modifiedField.Equals(FieldModified.Label))<br />
{<br />
copiedRow[classLabel] = newValue;<br />
}<br />
else if (modifiedField.Equals(FieldModified.Name))<br />
{<br />
copiedRow[classLabel] = newValue;<br />
}<br />
<br />
mainDataSet.Tables["Modified" + nodeTag.ClassName].Rows.Add(copiedRow);<br />
mainDataSet.Tables["Modified" + nodeTag.ClassName].AcceptChanges();<br />
}
|
|
|
|
|
I fixed the error, by mistake i wasnt going through the in-correct data collection. The deadly copy and paste from another section of my code was to blame!
-- modified at 9:16 Tuesday 12th December, 2006
|
|
|
|
|
Hi,
I have a treeview in my application and a
righthand click on a node should have the
same behavior as a lefthand mouseclick.
For the lefthand mouseclick I use the eventhandler
<br />
private void treeViewServer_AfterSelect(object sender, TreeViewEventArgs e)<br />
{<br />
} <br />
The righthand click should call the same handler. But
the eventhandler "click" of the treeview
<br />
private void treeViewServer_Click(object sender, EventArgs e)<br />
{<br />
}<br />
provides not the TreeViewEventArgs of the "AfterSelect"
Some ideas?
Thanx in advance
Erik
|
|
|
|
|
very urgent..
Now I am doing a project.The core of the project is the
conversion of AVI format into 3GP. I cannot get any code from net
please anybody help me
Abhilash
|
|
|
|
|
Search for mencoder, maybe you con P/invoke this stuff?
else you can read the code and implement it in c#
|
|
|
|
|
Hello everyone,
I am programming with Window Mobile and I heard that in the .Net SDK supports not only web service SDK at client side, but also offline web service module support? That is really cool!
Could anyone recommend some samples/tutorials on this topic?
thanks in advance,
George
|
|
|
|
|
This sounds like you are talking about Smart Clients. Try this article for a view:
http://www.codeproject.com/smartclient/SmartClientSOA.asp[^]
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks Pete! The smart client is only for desktop application, other than for Windows Mobile application, right?
What I need is the ability to provide offline Web Services function for Windows Mobile application. Any comments?
regards,
George
|
|
|
|
|
George - the whole concept works for both Desktop and Mobile applications (in fact, I would say that it is better for mobile than desktop apps). Have you looked at the Smart Client Application Blocks or the Smart Device Framework?
http://opennetcf.com/CompactFramework/Products/SmartDeviceFramework/tabid/65/Default.aspx/[^]
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks for reply Pete! I have read through the document and related samples, and they are very informative. But, ... , I have not found any information about offline Web Services support ...
Maybe I am wrong or careless. Could you kindly point it from the URL/document you mentioned please?
regards,
George
|
|
|
|