|
|
Hi,
I want to remove the focus from a combo box upon choosing an item. The reason being so that the items in the drop-down list can't be changed by the mouse-wheel. How can I achieve this please?
C.N.
|
|
|
|
|
spvemm@hotmail.com wrote:
I want to remove the focus from a combo box upon choosing an item.
Well, the question is, what control do you want to give the focus to? Just call the Focus method of the control you want to set the focus to, and the combobox will lose the focus.
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
ok....that solved the problem....10x a lot.
C.N.
|
|
|
|
|
Hi
In VS 2005, there is no .vbproj or .csproj for webprojects. Now how we can identify the existing project is web or local by using c#? In VS 2005 we can use Project.Properties.Item("ProjectType").Value . But in VS 2005 it throws an exception for web projects. If any one know how we can solve this problem, please help me.
Regards,
Rathish P S
|
|
|
|
|
Hi!
i have a Int16 variable and it has the value 0x010C. (little endian).
I want to get highbyte value and lowbyte value but don't know how to go on.
Is it correct to do the following to get the highbyte value?
int highbyte = Int16 & 0x00FF;
I am confused because i read that display of variable value (0x010C) != storing variable in memory (little endian).
Thx for help.
|
|
|
|
|
zuschauer1980 wrote:
int highbyte = Int16 & 0x00FF;
No, the high byte is the byte with the higher numeric value, so, it would be:
Int16 & 0xFF00
because FF00 > 00FF
[edit]Oops! That's actually not why it's the high byte. It's the high byte because it's higher in memory! It's probably less confusing if you talk in terms of the MSB and LSB (most significant byte and least significant byte[/edit]
But this just leaves the byte in the high byte position. What you probably want is something more like:
byte b=(byte)((Int16 & 0xFF00) >> 8);
Marc
MyXaml
Advanced Unit Testing
YAPO
|
|
|
|
|
Do this
Int16 val = 0x010C;
byte highVal = (byte)((val >> 8) & 0x00FF);
byte lowVal = ((byte) val & 0x00FF);
You needn't worry about the endianness, as both 0x00FF and your variable will be stored the same way in memory. Even if it is stored as 0C 01 in memory, when your program issues a CPU instruction to read a 16 bit value, you'll get back 0x010C.
So whatever the endianness, in your program, 0x01 is the high byte and 0x0C is the low byte.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
To get the high byte value (i.e. 0x01 in your example) use:
byte highByte = (byte) ( ( Int16 >> 8 ) & 0xFF );
byte lowByte = (byte) ( Int16 & 0xFF ); The right-shift operation moves all the bits in the number rightwards 8 places, moving the bits in the high-byte positions into the low-byte positions. The AND operation masks the bits you want to ignore for this operation.
Whether the memory storage is big- or little-endian doesn't really matter if you're using logic operations like this. What counts is how the processor sees it. In C you can do things like getting the raw addresses and reading the byte at the appropriate offset which is theoretically faster, but is also affected by the endian-ness of the CPU.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thx for that clear description to you and all others!
now i have the second question...
one of these bytes is two's complement and should be transposed with the other byte. how have i to handle this?
|
|
|
|
|
Two's complement, if I recall it correctly, basically is:
Negate
Add one
If you store an Int16, either both bytes are two's complement of the original integer or both bytes are "plain" integer. There is no "mix".
Additionally, if you have not calculated two's complement yourself, you should not have to "reverse" it by hand.
I mean: If you shove "1823" into a variable and then print it, you will still get "1823", even if "1823" is stored as two's complement in memory.
That also means that the approach written in prior posts will still work, as you are manipulating the "1823", not two's complement of "1823".
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
ah you are right. two`s complement is just a way to store binary negative numbers. so when i make read access i will have the real value in the integer variable.
thx, for your thoughts.
|
|
|
|
|
Hi,
I have a checkedlistbox (clb) which populates on the form_load event and another listbox (lb) which is populated by the choices made in the clb.
The code to populate the lb is as follows
private void lbTerritoryAll_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
{
if( e.NewValue == CheckState.Checked)
{
lbTerritorySelected.Items.Add(lbTerritoryAll.SelectedItem.ToString());
}
else
{
lbTerritorySelected.Items.Remove(lbTerritoryAll.SelectedItem.ToString());
}
}
The problem is that in the 2nd listbox, all that appears is System.Data.DataRowView
My question is how can I make the data in the lb appear as correct text?
This is on a Windows form, not a webform.
Hope someone can help, thanks in advance
Scotty
|
|
|
|
|
Calling ToString on a DataRowView object will give you exactly what you are seeing in the ListBox .
A possible solution would be to cast the SelectedItem to DataRowView and then explicitely tell what info you want to be displayed:
lbTerritorySelected.Items.Add((lbTerritoryAll.SelectedItem as DataRowView)[columnIndexToShow].ToString());
|
|
|
|
|
Hi
I want to delete the particular node from xml file
Supoose i want to delete farm name="ram" it should delete all the contents of element farm
Program should search from the file for particular node and delete
This is my original XMl structure
<?xml version="1.0" encoding="UTF-8"?>
<root>
<farm-config>
<farm name="ram">
<connection address="localhost" user="ram" password="ram">
<lastjob>Copy-All</lastjob>
<lastconnection startdate="2005-05-10" starttime="12:43:23" enddate="2005-05-10" endtime="12:58:32" />
<state>1</state>
<database start="0" name="bd_plc1_house1_14022005" sourceType="amacs">
<tables state="0" name="feed_delivery">
<columns state="0" name="DATE" />
<columns state="0" name="TIME" />
<columns state="0" name="DAY" />
<columns state="0" name="MONTH" />
<columns state="0" name="YEAR" />
<columns state="0" name="PRODWEEK" />
<columns state="0" name="WEEKDAY" />
<columns state="0" name="SILO" />
<columns state="0" name="CAR" />
<columns state="0" name="PRODUCT" />
<columns state="0" name="VOLUME" />
</tables>
</database>
</connection>
</farm>
<farm name="dev2">
<connection address="localhost1" user="root1" selectedConnection="1" password="daask2">
<lastJob>Copy-All</lastJob>
<lastConnection startdate="2005-05-10" starttime="12:43:23" enddate="2005-05-10" endtime="12:58:32" />
<state>1</state>
</connection>
<database state="0" name="bd_plc1_house1_14022005" sourceType="amacs">
<tables state="0" name="feed_delivery">
<columns state="0" name="DATE" />
<columns state="0" name="TIME" />
<columns state="0" name="DAY" />
<columns state="0" name="MONTH" />
<columns state="0" name="YEAR" />
<columns state="0" name="PRODWEEK" />
<columns state="0" name="PRODDAY" />
<columns state="0" name="WEEKDAY" />
<columns state="0" name="SILO" />
<columns state="0" name="CAR" />
<columns state="0" name="PRODUCT" />
<columns state="0" name="VOLUME" />
</tables>
<tables state="0" name="production_actualbirds">
<columns state="0" name="DATE" />
<columns state="0" name="TIME" />
<columns state="0" name="DAY" />
<columns state="0" name="MONTH" />
<columns state="0" name="YEAR" />
<columns state="0" name="PRODWEEK" />
<columns state="0" name="PRODDAY" />
<columns state="0" name="WEEKDAY" />
<columns state="0" name="SILO" />
<columns state="0" name="CAR" />
<columns state="0" name="PRODUCT" />
<columns state="0" name="VOLUME" />
</tables>
</database>
</farm>
</farm-config>
</root>
after deletetion my xml structure will look like in the given format
<?xml version="1.0" encoding="UTF-8"?>
<root>
<farm-config>
<farm name="dev2">
<connection address="localhost1" user="root1" selectedConnection="1" password="daask2">
<lastJob>Copy-All</lastJob>
<lastConnection startdate="2005-05-10" starttime="12:43:23" enddate="2005-05-10" endtime="12:58:32" />
<state>1</state>
</connection>
<database state="0" name="bd_plc1_house1_14022005" sourceType="amacs">
<tables state="0" name="feed_delivery">
<columns state="0" name="DATE" />
<columns state="0" name="TIME" />
<columns state="0" name="DAY" />
<columns state="0" name="MONTH" />
<columns state="0" name="YEAR" />
<columns state="0" name="PRODWEEK" />
<columns state="0" name="PRODDAY" />
<columns state="0" name="WEEKDAY" />
<columns state="0" name="SILO" />
<columns state="0" name="CAR" />
<columns state="0" name="PRODUCT" />
<columns state="0" name="VOLUME" />
</tables>
<tables state="0" name="production_actualbirds">
<columns state="0" name="DATE" />
<columns state="0" name="TIME" />
<columns state="0" name="DAY" />
<columns state="0" name="MONTH" />
<columns state="0" name="YEAR" />
<columns state="0" name="PRODWEEK" />
<columns state="0" name="PRODDAY" />
<columns state="0" name="WEEKDAY" />
<columns state="0" name="SILO" />
<columns state="0" name="CAR" />
<columns state="0" name="PRODUCT" />
<columns state="0" name="VOLUME" />
</tables>
</database>
</farm>
</farm-config>
</root>
waiting for the response with code
regards
sanjeev
|
|
|
|
|
load the xml into a XmlDocument then say
something like -
<br />
XmlNode nd = doc.DocumentElement.SelectSingleNode("//farm-config/farm[@name='ram']");<br />
doc.DocumentElement.RemoveChild(nd);<br />
|
|
|
|
|
hello everybody
I'm really stuck !!!
I want to serialize information of a whole listbox (which is a list of users).
it is a list of users that I can add a new user or delete, and the pick on of them and log in.
its all really simple when it comes to one user but when I'm trying to make multiple by using sting[] I just keep on encountering exceptions of null values and practically it only saves the last user added.
anyone can help me with this???
THANKS!
|
|
|
|
|
Save a number, then that number of strings, one at a time.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
aaa... I don't quite understand what you mean....
|
|
|
|
|
What is the problem?Can you post your code here??
I think he is saying that you should save number of elements in the array , then retrieve it .
|
|
|
|
|
okay, thaX!
thats my serializing class:
[code]
[Serializable()]
public class serialize : ISerializable
{
public string[] strText;
public serialize() //default constructor
{
//
}
//Deserialization constructor.
public serialize(SerializationInfo info, StreamingContext ctxt)
{
Form1 main = new Form1();
for(int cnt = 0 ; cnt < main.lbList.ItemHeight ; cnt++)
strText[cnt] = (String)info.GetValue("srlText"+cnt.ToString(), typeof(string[]));
}
//Serialization function.
public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{
Form1 main = new Form1();
for(int cnt = 0 ; cnt < main.lbList.ItemHeight ; cnt++)
info.AddValue("srlText"+cnt.ToString(), strText[cnt]);
}
}
[/code]
what I'm trying to do is to create a new name and a new line in the strText array for each user.
in form1 I'm calling the serialization like this:
[code]
private void btnEnter_Click(object sender, System.EventArgs e)
{
serialize save = new serialize();
enteritem AddItem = new enteritem();
save.strText[0] = AddItem.txtText.Text; //just to try it out I'm using index 0.
Stream stream = File.Open("text.sav", FileMode.OpenOrCreate);
BinaryFormatter bformatter = new BinaryFormatter();
bformatter.Serialize(stream, save);
stream.Close();
}
[/code]
in this line:
Stream stream = File.Open("text.sav", FileMode.OpenOrCreate);
I'm getting an exception
|
|
|
|
|
OK, I think the prolem is not at opening file,
its because you didnt initilize the string array
try add this :
save.strText = new string [100];
// your code
save.strText[0] = AddItem.txtText.Text;
|
|
|
|
|
Thanks!
it worked!
But (there is always a but...),
before that I created a loading function that supposed to update a listbox from that serializing, so now I'm getting an exception over there (System.Reflection.TargetInvocationException), and I really don't understand why, everything looks great!
this is the code of that function:
public void UpdateList()
{
serialize load = new serialize();
Stream stream = File.Open("text.sav", FileMode.OpenOrCreate);
BinaryFormatter bformatter = new BinaryFormatter();
try
{
load = (serialize)bformatter.Deserialize(stream); //THIS LINE GETS THE EXCEPTION.
for(int cnt = 0 ; cnt < lbList.ItemHeight ; cnt++)
lbList.Items.Add(load.strText[cnt]);
}
catch(System.Runtime.Serialization.SerializationException)
{
MessageBox.Show("System.Runtime.Serialization.SerializationException");
}
catch(System.ArgumentNullException)
{
MessageBox.Show("System.ArgumentNullException");
}
stream.Close();
}
Thanks alot in advance!
|
|
|
|
|
hi, i am writting a c# windows project, i want to call a java class throgh it, so any one can help me to be able to call java class through my project to be able to use the functions sttored in this java class
Thanks alot
Hamody
|
|
|
|
|
Java converts easily to C#. If you need to call code in an existing app, I'd guess you are screwed. Perhaps J# can help, somehow ? I'm thinking Java uses CORBA, perhaps J# does too, and can be interoped to C# as well.
Christian Graus - Microsoft MVP - C++
|
|
|
|