|
Thanks for your support.
I've found the way to load pID and productname; but my second question I've not found it yet.
How to do that? HELP ... !
Chuon Visoth
Angkor Wat - Cambodia
asp.net - c sharp beginner
|
|
|
|
|
|
Hi,
I am writing a program that needs to manipulate Animation Master's models(an 3d animation program).
Hash Inc have available an sdk for developing plug ins using C++. But they have an ActiveX that exposes all the sdk libruary, it's called WebHAMR.
I really need to do what I need to do fast, and because of this I am using C# Express 2008.
I really don't want to do it in C++
This is what I do:
I add WebHAMR as a Reference, And it works fine if I just place a WebHAMR control on a form and load a 3d model.
The problem I am having is that if I create an object using the library exposed by WebHAMR, I get the following error:
Retrieving the COM class factory for component with CLSID {2FDB515C-EA6A-4B4A-8300-A0446FEB7F78} failed due to the following error: 80040154.
I really need help, I am limited on time.
Thanks
|
|
|
|
|
I have a localized form set up with default, en-CA and fr-CA languages. I tried testing the form, for each of the languages by changing the HKCU\Software\Policies\Microsoft\Control Panel\Desktop\MultiUILanguageID value between 0409 (en-US), 1009 (en-CA) and 0C0C (fr-CA). The correct localized text is displayed everytime I test the form without debugging but not when I test using VS debugger.
Here's what I do:
1. Create a localized form with a button which closes the form.
2. Update HKCU\Software\Policies\Microsoft\Control Panel\Desktop\MultiUILanguageID value to 0C0C (was originally 0409)
3. From Visual Studio IDE window, choose "Start without Debugging"
4. Form displays with French text as expected
5. Update HKCU\Software\Policies\Microsoft\Control Panel\Desktop\MultiUILanguageID value to 1009
6. From Visual Studio IDE window, choose "Start without Debugging"
7. Form now displays with Canadian English text - again, as expected
8. Update HKCU\Software\Policies\Microsoft\Control Panel\Desktop\MultiUILanguageID value back to 0C0C
9. From Visual Studio IDE window, choose "Start Debugging"
10. Form displays with Canadian English text - expected to be French
11. Repeat step 9 above - without touching the registry value (still 0C0C)
12. Form now displays in French as expected
I noticed that if I want the form to display in the correct language, in debug mode, I need to run it twice after changing the registry value.
I test by changing HKCU\Software\Policies\Microsoft\Control Panel\Desktop\MultiUILanguageID value because I don't want to change locale in Control Panel everytime. Is this test valid? If so, does anyone know why my test results are different between "Debug" and 'non-Debug"?
Thank you.
cpl
|
|
|
|
|
Hello
I am trying to update record in a database. I can see the changes in the datagrid, but they don't get saved into the database.. The 3 textboxes show the values of the currently selected row in the datagrid. So i press the Change button to make the textboxes active, change the text and then click the Save button.
Here's how the form looks like: http://img529.imageshack.us/my.php?image=45903634.jpg
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
private SqlConnection conn;
private string connStr;
SqlDataAdapter da;
DataSet ds;
bool b;
public Form1()
{
InitializeComponent();
connStr = "Data Source=.\\SQLEXPRESS;AttachDbFilename=" + Application.StartupPath + "\\dbOne.mdf" + ";Integrated Security=True;Connect Timeout=30;User Instance=True";
conn = new SqlConnection(connStr);
conn.Open();
string selectStr = "select * from people";
da = new SqlDataAdapter(selectStr, conn);
ds=new DataSet();
da.Fill(ds,"people");
da.InsertCommand = new SqlCommand("insert into people(name, age) values (@name, @age)", conn);
da.InsertCommand.Parameters.Add("@name",SqlDbType.VarChar,50,"name");
da.InsertCommand.Parameters.Add("@age",SqlDbType.Int,5,"age");
da.UpdateCommand = new SqlCommand("update people set name=@name, age=@age where id=@id",conn);
da.UpdateCommand.Parameters.Add("@name",SqlDbType.VarChar,50,"name");
da.UpdateCommand.Parameters.Add("@age",SqlDbType.Int,5,"age");
da.UpdateCommand.Parameters.Add("@id",SqlDbType.Int,5,"id");
da.DeleteCommand = new SqlCommand("delete from people where id=@id",conn);
da.DeleteCommand.Parameters.Add("@id",SqlDbType.Int,5,"id");
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.DataSource = ds.Tables["people"];
txtId.DataBindings.Add("Text",ds.Tables["people"],"id");
txtName.DataBindings.Add("Text", ds.Tables["people"], "name");
txtAge.DataBindings.Add("Text", ds.Tables["people"], "age");
txtId.Enabled = false; txtName.Enabled = false; txtAge.Enabled = false;
btnSave.Enabled = false; btnCancel.Enabled = false;
conn.Close();
}
private void btnChange_Click(object sender, EventArgs e)
{
b = false;
txtName.Enabled = true; txtAge.Enabled = true;
btnNew.Enabled = false; btnDelete.Enabled = false; btnSave.Enabled = true; btnCancel.Enabled = true;
}
private void btnSave_Click(object sender, EventArgs e)
{
if (b)
{
DataRow newLine = ds.Tables["people"].NewRow();
newLine["name"] = txtName.Text;
newLine["age"] = txtAge.Text;
ds.Tables["people"].Rows.Add(newLine);
}
da.Update(ds,"people");
}
private void btnNew_Click(object sender, EventArgs e)
{
b = true;
int i = ds.Tables["people"].Rows.Count;
dataGridView1.Rows[i].Selected = true;
txtId.Text = ""; txtName.Text = ""; txtAge.Text = "";
txtName.Enabled = true; txtAge.Enabled = true;
btnSave.Enabled = true; btnCancel.Enabled = true;
}
private void btnDelete_Click(object sender, EventArgs e)
{
int i = int.Parse(dataGridView1.CurrentRow.Index.ToString());
ds.Tables["people"].Rows[i].Delete();
da.Update(ds,"people");
}
}
}
|
|
|
|
|
Your Code is very Ugly, you are not even trapping exceptions, and you open connections at wrong places.
This is how you update a Datagrid
[^]
Hope it Helps
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Everytime i multiselect files it creates so many tabs as files selected..but there is only text of first file in first tab..other tabs are empty...
Here i have code for opening file:
private void evtOpenFile_Click(object sender, EventArgs e)
{
openFileDialog1.Multiselect = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
foreach (String file in openFileDialog1.FileNames)
{
evtNewDocument_Click(sender, e);
RichTextBox richTextBox1 = new RichTextBox();
richTextBox1 = tabControl1.SelectedTab.Controls[0] as RichTextBox;
richTextBox1.LoadFile(openFileDialog1.FileName,RichTextBoxStreamType.PlainText);
saveFileDialog1.FileName = openFileDialog1.FileName;
FileInfo fi = new FileInfo(openFileDialog1.FileName);
string pot = fi.Name;
tabControl1.SelectedTab.Text = pot;
pot = "";
}
}
}
evtNewDocument_Click(sender, e); creates new tab in tabcontrol with selectedindex on it! Still can't figure out what is wrong... PLZ HELP!
THanks
|
|
|
|
|
Aljaz111 wrote: richTextBox1 = tabControl1.SelectedTab.Controls[0] as RichTextBox;
for each iteration of the foreach this statement acts exactly the same, AFAIK SelectedTab is not changing (unless there is something hidden inside evtNewDocument_Click that succeeds in changing the tab whilst inside the evtOpenFile_Click, so the GUI thread is busy and not acting on extra messages right now).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
TabPage newPage = new TabPage();
newPage.Text = "Nov"+tabControl1.TabPages.Count;
tabControl1.TabPages.Add(newPage);
tabControl1.SelectedIndex = i;
i++
I am changing selectedindex..Something is wrong with changing to next text file.. In all tabs richtextboxes is text from first file in multiselect..
modified on Wednesday, May 27, 2009 8:13 PM
|
|
|
|
|
Sorry, I missed that.
There is one mistake though, you foreach "file" but never use it, instead you use "openFileDialog1.FileName" all the time, which isn't right. That would make all textboxes show the same text.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
|
Aljaz111 wrote: What should i change??
the only thing that changes value for each iteration of the foreach is the "file" variable, so you should USE it where ever you need to do something to one of the many files you are handling one by one.
If the code inside the foreach block does not rely on "file" it will perform the same actions over and over again, always using the same data.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
So where to use file?...Or can i walk through files in some other way?
|
|
|
|
|
Hint: what do you think openFileDialog1.FileName is holding when multiple files are selected?
Suggestion: buy a tutorial book on C# and work your way through it, you will acquire a lot of knowledge and insight from it.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I got it..thanks for letting me think;)
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi.
Could you guide me what the equal of this struct is in C# ?
struct chromo_typ
{
string bits;
float fitness;
chromo_typ(): bits(""), fitness(0.0f){};
chromo_typ(string bts, float ftns): bits(bts), fitness(ftns){}
};
Thanks
|
|
|
|
|
I must be getting really rusty with my C++ (It has been about 8 years) that I don't even know what some of this means any more:
chromo_typ(): bits(""), fitness(0.0f){};
chromo_typ(string bts, float ftns): bits(bts), fitness(ftns){}
What does the code after the colons do?
Man who stand on hill with mouth open wait long time for roast duck to drop in
|
|
|
|
|
Colin Angus Mackay wrote: What does the code after the colons do?
this struct has been used like this :
chromo_typ temp[POP_SIZE];
temp[cPop++] = chromo_typ(offspring1, 0.0f);
temp[cPop++] = chromo_typ(offspring2, 0.0f);
|
|
|
|
|
This demonstraits potential usage. It doesn't explain what the code after the colons on each line do. However, jimmanuel's explanation of how to convert your code to C# explains it.
Man who stand on hill with mouth open wait long time for roast duck to drop in
|
|
|
|
|
public class chromo_typ
{
public string bits { get; set; }
public float fitness { get; set; }
public chromo_typ() { bits = ""; fitness = 0.0f; }
public chromo_typ(string bts, float ftns) { bits = bts; fitness = ftns; }
}
I do believe this is right.
|
|
|
|
|
the float and string member variables are straightforward and the struct should be a class in C# (unless you have good reason to use a struct). The tricky stuff comes after that.
This
chromo_typ(): bits(""), fitness(0.0f){}; is a constructor with minimal code formatting, here's an expanded version that's a bit easier on the eyes:
chromo_typ() :
bits(""),
fitness(0.0f)
{
}; That's a parameterless constructor with an initialization list (you can google that for more info). A very similar way of writing that constructor would be this:
chromo_typ()
{
bits = "";
fitness = "0.0f;
}; Now, in C++ there are subtles difference between those two versions of the function but for the purposes of the C++ -> C# conversion you needn't worry about them. This version of the function is another pretty straightforward conversion from one language to the other.
The second chromo_typ(...) line is just another constructor with some parameters. You should be able to convert that one the same way as the first
|
|
|
|
|
This is a performance issue: Struct vs. Class. I'm at that point in development where I need to make the app more stable. The program is a truck control and monitor system. Right now the app can have any number of trucks, let's say 5. Each has an engine, the shape of the information will be given later. The child form per truck has controls to change RPM, GEAR, and Pressure as well as gauges to monitor various other aspects of information being sent back to the form from the actual engine. Needless to say this makes for all trucks to be observable a little hard on one screen. This is where the truck monitor comes in, a smaller version with bear minimum, to have all trucks on screen.
I've designed where each truck gets a time slice since we're using RS-232. We're locked into this there is no negotiating this point. Each truck writes to, receives from the engine, process information, writes to file, and eventually send to monitor child form. All this occurs at 250 ms per truck.
Each truck has a monitor for mostly display and contains three controls.
As to the processing, each truck listen to incoming port, for properly formed string data, parses the data, assigns proper portion to the right variable of the engine and gauges. Such as, rpm info is place in engine.rpm_var and so on.
All this is accomplished through a loop on the parent form, MainController. This parent form has the comport portion,RS-232, here. The loop looks this:
Indiv_Truck_Cntrl tempChild = (Indiv_Truck_Cntrl)this.MdiChildren[trxx];
{
Truck_Active.Text = tempChild.Name;
Main_Serial_Port1.Write(tempChild.port_out);
test_port = Main_Serial_Port1.ReadExisting();
if (test_port == "")
{
}
else
{
Send_Truck_Info(test_port);
}
tempChild.SEND_SETTINGS_Click();
So the question here is do I use a class or a struct for the information I need, that is for Engine. Right now I have my Engine defined as:
public class Engine
{
private string c_TRUCK_ID;
public string TRUCK_ID
{
get { return c_TRUCK_ID;} set { c_TRUCK_ID = value;}
}
private string c_TRUCK_NUM;
public string TRUCK_NUM
{
get { return c_TRUCK_NUM;} set { c_TRUCK_NUM = value; }
}
private string c_TRUCK_IP;
public string TRUCK_IP
{
get { return c_TRUCK_IP;} set { c_TRUCK_IP = value;}
}
public string RPM = "RPM";
private string c_RPM_var;
public string RPM_var
{
get { return c_RPM_var;} set { c_RPM_var = value;}
}
public string GEAR = "GEAR";
private string c_GEAR_var;
public string GEAR_var
{
get { return c_GEAR_var;} set { c_GEAR_var = value;}
}
private string c_GEAR_Name;
public string GEAR_Name
{
get { return c_GEAR_Name; } set { c_GEAR_Name = value; }
}
public string OIL_PRES = "OIL PRESSSURE ENG";
private string c_OIL_PRES_var;
public string OIL_PRES_var
{
get { return c_OIL_PRES_var;} set { c_OIL_PRES_var = value;}
}
public string COOLANT_TEMP = "COOLANT TEMP ENG";
private string c_COOLANT_TEMP_var;
public string COOLANT_TEMP_var
{
get { return c_COOLANT_TEMP_var;} set { c_COOLANT_TEMP_var = value;}
}
public string BAT_VOLT = "BATTERY VOLTAGE";
private string c_BAT_VOLT_var;
public string BAT_VOLT_var
{
get { return c_BAT_VOLT_var;} set { c_BAT_VOLT_var = value;}
}
public string TRANS_OUT_RPM = "TRANSMISSION OUTPUT RPM";
private string c_TRANS_OUT_RPM_var;
public string TRANS_OUT_RPM_var
{
get { return c_TRANS_OUT_RPM_var; } set { c_TRANS_OUT_RPM_var = value; }
}
public string FUEL_PRESS = "FUEL PRESSURE ENG";
private string c_FUEL_PRESS_var;
public string FUEL_PRESS_var
{
get { return c_FUEL_PRESS_var; } set { c_FUEL_PRESS_var = value; }
}
public string LOCKUP_CONV = "LOCKUP CONVERTER";
public string c_LOCKUP_CONV_var;
public string LOCKUP_CONV_var
{
get { return c_LOCKUP_CONV_var; } set { c_LOCKUP_CONV_var = value; }
}
public string OVER_PRESS = "OVER_PRESS SETPOINT";
private string c_OVER_PRESS_var;
public string OVER_PRESS_var
{
get { return c_OVER_PRESS_var; } set { c_OVER_PRESS_var = value; }
}
public string FRAC_PRESS = "FRAC PRESSURE";
private string c_FRAC_PRESS_var;
public string FRAC_PRESS_var
{
get { return c_FRAC_PRESS_var;} set { c_FRAC_PRESS_var = value;}
}
public string PUMP_LUBE_PRESS = "PUMP LUBE PRESSURE";
private string c_PUMP_LUBE_PRESS_var;
public string PUMP_LUBE_PRESS_var
{
get { return c_PUMP_LUBE_PRESS_var;} set { c_PUMP_LUBE_PRESS_var = value;}
}
public string PUMP_LUBE_TEMP = "PUMP_LUBE TEMPERATURE";
private string c_PUMP_LUBE_TEMP_var;
public string PUMP_LUBE_TEMP_var
{
get { return c_PUMP_LUBE_TEMP_var;} set { c_PUMP_LUBE_TEMP_var = value;}
}
public string PUMP_FLOW = "PUMP FLOW RATE";
private string c_PUMP_FLOW_var;
public string PUMP_FLOW_var
{
get { return c_PUMP_FLOW_var;} set { c_PUMP_FLOW_var = value;}
}
public string ENG_HRS = "ENGINE HOURS";
private string c_ENG_HRS_var;
public string ENG_HRS_var
{
get { return c_ENG_HRS_var;} set { c_ENG_HRS_var = value;}
}
public string ENG_TYPE = "ENGINE TYPE";
private string c_ENG_TYPE_var;
public string ENG_TYPE_var
{
get { return c_ENG_TYPE_var;} set { c_ENG_TYPE_var = value;}
}
private string c_ENG_TYPE_name;
public string ENG_TYPE_name
{
get { return c_ENG_TYPE_name;} set { c_ENG_TYPE_name = value;}
}
public string TRANS_TYPE = "TRANSMISSION TYPE";
private string c_TRANS_TYPE_var;
public string TRANS_TYPE_var
{
get { return c_TRANS_TYPE_var;} set { c_TRANS_TYPE_var = value;}
}
private string c_TRANS_TYPE_name;
public string TRANS_TYPE_name
{
get { return c_TRANS_TYPE_name;} set { c_TRANS_TYPE_name = value;}
}
public string DIAG = "DIAGNOSTICS";
private string c_DIAG_var;
public string DIAG_var
{
get { return c_DIAG_var; } set { c_DIAG_var = value; }
}
}
It works now, but for better performance as far as memory management, aka. Garbage collection what's better?.
I've been reading on the class/struct thing, reference vs. value. I 'm leaning toward struct for performance and hopefully stability. I need the ability for each truck to have the ability to take and hold information. I could always figure away to pass the info to the monitor form
This below is what I've found:
You want your type to look and feel like a primitive type.
You create a lot of instances, use them briefly, and then drop them. For e.g., within a loop.
The instances you create are not passed around a lot.
You don't want to derive from other types or let others derive from your type.
You want others to operate on a copy of your data (basically pass by value semantics).
I'm I right to think to changing to a struct and if so what should the struct even look like? I hope this is enough detail.
One last question, is the class Engine complex enough to stay a class or can I safely change to a struct?
Thanks
|
|
|
|
|
From your summry, it sems you've read this[^] article.
If you read the section when not to use stucts you will see
"should ideally be below 16 bytes".
For that reason alone, with all those strings it's gonna be way above that, so stick with the class.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I'd leave them as class es.
Worrying about performance differences between class and struct is generally a waste of effort; "performance" is not a reason to choose one over the other.
A truck is not a value, you don't perform operations with it.
|
|
|
|
|