|
Maybe that with a sample of the code (and of the file) you will make our lives far easier... )
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Unless you actually show the code that you tried, the only thing that anyone can say about it is that it's wrong.
I assume that the example that you showed was not an actual value that you are using, as they have totally different bit patterns? It would be more helpful if you showed some real examples of what you are using. Any information that you withhold is directly affecting the assistance that you can get.
---
b { font-weight: normal; }
|
|
|
|
|
OK apologies for not being very precise. The file I am dealing with is very large and the packed information forms a very small part of it. When extracted it has to go through another transformation. What I am trying to understand is generally how to write a function which will take a set of bits out of a larger set and return their value as an Integer. For example if I have 32 bits in a UInt32 then this is what I tried:
public static UInt32 Dword (UInt32 data, int start, int end) {
UInt32 result = data << (31-end+1);
result = result >> (31 - end + 1 + start);
return result;
}
I am sure the code is very poor with magic numbers and so on but if I take the example of cutting out bits 3 thru 7 inclusive then I left shift to remove bits 8 thru 31 then right shift until bit 3 is not bit 0. I have absolutely no experience of dealing with bit manipulation.
Apologies again if I am not clear but it is because I really don't know what I am doing here
Jon
|
|
|
|
|
Hi,
both +1 terms should be dropped, as you can see from these simple cases:
if you want all bits (so start=0, end=31) then no shifting should occur.
if you want the LSB (start=end=0) then it should read (data<<31)>>31
if you want the MSB (start=end=31) then it should read (data<<0)>>31
When shifting one more in both directions, you actually loose the most significant bit of
your bit field.
Luc Pattyn
|
|
|
|
|
Instead of shifting the data back and forth to get rid of unwanted bits, use a bit mask.
If you want bits 3 through 7, use a bit mask where those bits are set to one, and use the binary and operator (&) to clear the unwanted bits:
mask = 0x00f8;<br />
data = data & mask;
Then shift the data the three bits to place it at bit zero and up:
data = data >> 3;
---
b { font-weight: normal; }
|
|
|
|
|
OK Thank you everyone - it is now working
Jon
|
|
|
|
|
hi...
In my MDI application , i have one child form(ChildForm) & object of that form i am adding on every click of one MenuItem(i have three Menu items- ManuItem1,Manuitem2 & menuItem3) in my parent form & on click of the MenuItems i'm making that form(ChildForm) as a child form of my parent & i am displaying that child form. Now i want that child form to have three ToolStripButtons & three events for that toolstripbuttons.
i have added 3 ToolStripButtons while making that ChildForm initiallly only. I have made them public also but they are not available when i want to access them in my ParentForm class. I am clicking each MenuItem & declaring object for childForms. I am able to dispaly the form but i am not able to access those ToolStripButtons. I have a RichtextBox as other Control on that Form.
How i can do this...?
Thanks & regards,
Vinay
|
|
|
|
|
hi everyone, im having a strange problem connecting to .mdb file from c#, while the same application is connecting fine with oracle, each time i made some changes in the forms and save them using the binding navigator tool strip, the changes are not saved the next time i open it, please help
|
|
|
|
|
Hello everyone,
I am wondering whether there are any tools that can convert Java source codes to C# source codes? I have a simple Java program, which uses only basic Java classes and some JDBC/Swing classes to do database/GUI functions.
thanks in advance,
George
|
|
|
|
|
Google
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
It seems that you are an expert, any recommendations?
regards,
George
|
|
|
|
|
Hi,
How can i call a function from another when i only have the name of the function in a string parameter. I want to call the second function with the designated parameters and get the return value.
<br />
public double F2(string param1, int param2)<br />
{<br />
<br />
}<br />
<br />
public void F1(string FunctionName)<br />
{<br />
}<br />
Please help
Do your best to be the best
|
|
|
|
|
double res;
res = F2("",0);
or
F2("",0);
|
|
|
|
|
You need to use Reflection here.
The following code is not complete but I think it will help you.
using System.Reflection;
.....
public void CallMethod(string methodName)
{
MethodInfo methodInfo = this.GetType().GetMethod(methodName);
if (methodInfo == null)
{
throw new MissingMethodException(this.GetType().Name,methodName);
}
methodInfo.Invoke(this, new object[] { "Param1", 50 });
}
public void MethodToBeCalled(string param1, int v)
{
Console.WriteLine(param1);
Console.WriteLine(v);
}
|
|
|
|
|
Why, oh why, would you identify the method using a string?
Perhaps you should explain what it is that you are trying to accomplish, instead of asking how it's done the way that you think that it should be done.
---
b { font-weight: normal; }
|
|
|
|
|
how can i add connection string in the web.config and how can i change the server name from this file by code?
fatma
|
|
|
|
|
web.config file
<connectionstrings>
<add name="Conn" connectionstring="..." providername="System.Data.SqlClient">
Code (to get the connection string):
System.Configuration.ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
As for changing the server you can try replacing in the string the existent IP address with another one
Do your best to be the best
|
|
|
|
|
<configuration>
<connectionStrings>
<add name="connectionStringName"
connectionString="Data Source=localhost; Initial Catalog=databaseName; uid=username; pwd=password;"/>
</connectionStrings>
</configuration>
|
|
|
|
|
hello everybody!!
iam generating a windows form which has a treeview at the left and a splitpanel at its right.
the treeview consists of 3 parent nodes with 1 child node in each parent node. the parent nodes have a contextmenu with "Start" and "Stop" as menu items and child nodes have a contextmenu with "Properties" as menuitem.
each of the menuitem has an OnClick event handler.
what i want is, on clicking the menuitem of each of the child nodes, a different panel should be displayed each time. for this, i need to have 3 panels, one for each childnode. when one panel is being displayed, others should be hidden. my requirement is something similar to the WindowsExplorer, but iam not able to generate the desired o/p.
Also, when i right-click on any of the node, the contextmenu is displayed, but after clicking the desired menuitem, the contextmenu just doesnt disappear.
am i missing some property tat has to be set for the contextmenu to disappear after selecting a menuitem?
this is a part of my code:
mnuParentMenu.MenuItems.Add(0, new MenuItem("Start", new System.EventHandler(mnuStart_Click)));<br />
mnuParentMenu.MenuItems.Add(1, new MenuItem("Stop", new System.EventHandler(mnuStop_Click)));<br />
mnuChildMenu.MenuItems.Add(0, = new MenuItem("Properties", new System.EventHandler(mnuPropertiesC_Click)));<br />
<br />
TreeNode node = new TreeNode("Parent");<br />
node.Tag = "ParentNodeMenu";<br />
node.ContextMenu = mnuParentMenu;<br />
treeView1.Nodes.Add(node);<br />
node = new TreeNode("Child");<br />
node.Tag = "ChildNodeMenu";<br />
node.ContextMenu = mnuChildMenu;<br />
treeView1.Nodes[0].Nodes.Add(node);
I would be thankful to all who wish to take some time and help me out.
Sonu
|
|
|
|
|
Sonu.T wrote: what i want is, on clicking the menuitem of each of the child nodes, a different panel should be displayed each time. for this, i need to have 3 panels, one for each childnode. when one panel is being displayed, others should be hidden. my requirement is something similar to the WindowsExplorer, but iam not able to generate the desired o/p.
How have you implemented it currently and what happens if you click on a child node? Simply setting the Visible property of the panel to be hidden to false and sending it to the back of the ZOrder using SendToBack should work fine, I think. Another approach would be to have a single panel, but different UserControl derived classes. That way, designing the UI would be easier.
Sonu.T wrote: Also, when i right-click on any of the node, the contextmenu is displayed, but after clicking the desired menuitem, the contextmenu just doesnt disappear.
I'm surprised that you even get the context menu. This[^] KB article shows how to add multiple context menus for different nodes to treeviews. Basically, you subscribe to the MouseUp event, get the point where the mouse was clicked, use the GetNodeAt method to get the TreeNode at that point and then show the appropriate popup menu.
|
|
|
|
|
hello Senthil
thanx for replying.
i understand that there is no clarity in my query....
iam pasting my entire code here...hope this wud make better sense
public partial class Form1 : Form<br />
{<br />
private System.Windows.Forms.ContextMenu mnuParentMenu = new System.Windows.Forms.ContextMenu();<br />
private System.Windows.Forms.ContextMenu mnuChildMenu = new System.Windows.Forms.ContextMenu();<br />
private MenuItem mnuStart;<br />
private MenuItem mnuStop;<br />
private MenuItem mnuProperties;<br />
private MenuItem mnuPropertiesC;<br />
private TreeNode m_OldSelectNode;<br />
private TreeNode node;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{ <br />
mnuParentMenu.MenuItems.Add(0, mnuStart = new MenuItem("Start", new System.EventHandler(mnuStart_Click)));<br />
mnuParentMenu.MenuItems.Add(1, mnuStop = new MenuItem("Stop", new System.EventHandler(mnuStop_Click)));<br />
mnuParentMenu.MenuItems.Add(2, mnuProperties = new MenuItem("Properties", new System.EventHandler(mnuProperties_Click)));<br />
<br />
mnuChildMenu.MenuItems.Add(0, mnuPropertiesC = new MenuItem("Properties", new System.EventHandler(mnuPropertiesC_Click)));<br />
<br />
node = new TreeNode("Credit Files");<br />
node.Tag = "ParentNodeMenu";<br />
node.ContextMenu = mnuParentMenu;<br />
treeView1.Nodes.Add(node);<br />
node = new TreeNode("VIO Copy Process");<br />
node.Tag = "ChildNodeMenu";<br />
node.ContextMenu = mnuChildMenu;<br />
treeView1.Nodes[0].Nodes.Add(node);<br />
<br />
node = new TreeNode("Human Resources");<br />
node.Tag = "ParentNodeMenu";<br />
node.ContextMenu = mnuParentMenu;<br />
treeView1.Nodes.Add(node);<br />
<br />
node = new TreeNode("Secondary Batch Update Process");<br />
node.Tag = "ChildNodeMenu";<br />
node.ContextMenu = mnuChildMenu;<br />
treeView1.Nodes[1].Nodes.Add(node);<br />
<br />
node = new TreeNode("TimeDeposits");<br />
node.Tag = "ParentNodeMenu";<br />
node.ContextMenu = mnuParentMenu;<br />
treeView1.Nodes.Add(node);<br />
<br />
node = new TreeNode("PurgeProcess");<br />
node.Tag = "ChildNodeMenu";<br />
node.ContextMenu = mnuChildMenu;<br />
treeView1.Nodes[2].Nodes.Add(node);<br />
<br />
node = new TreeNode("SecondaryBatchUpdateProcess");<br />
node.Tag = "ChildNodeMenu";<br />
node.ContextMenu = mnuChildMenu;<br />
treeView1.Nodes[2].Nodes.Add(node);<br />
splitContainer1.Visible = false;<br />
mnuStop.Enabled = false;<br />
<br />
}<br />
protected void mnuStart_Click(object sender, System.EventArgs e)<br />
{<br />
mnuStart.Enabled = false;<br />
mnuStop.Enabled = true; <br />
}<br />
protected void mnuStop_Click(object sender, System.EventArgs e)<br />
{<br />
mnuStop.Enabled = false;<br />
mnuStart.Enabled = true;<br />
}<br />
protected void mnuProperties_Click(object sender, System.EventArgs e)<br />
{<br />
splitContainer1.Visible = true;<br />
splitContainer1.Panel1Collapsed = false;<br />
splitContainer1.Panel2Collapsed = true;<br />
<br />
}<br />
protected void mnuPropertiesC_Click(object sender, System.EventArgs e)<br />
{<br />
splitContainer1.Visible = true;<br />
splitContainer1.Panel1Collapsed = true;<br />
splitContainer1.Panel2Collapsed = false;<br />
}<br />
private void treeView1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if (e.Button == MouseButtons.Right)<br />
{<br />
<br />
Point p = new Point(e.X, e.Y);<br />
<br />
TreeNode node = treeView1.GetNodeAt(p);<br />
if (node != null)<br />
{<br />
m_OldSelectNode = treeView1.SelectedNode;<br />
treeView1.SelectedNode = node;<br />
<br />
switch (Convert.ToString(node.Tag))<br />
{<br />
case "ParentNodeMenu":<br />
mnuParentMenu.Show(treeView1, p);<br />
break;<br />
case "ChildNodeMenu":<br />
mnuChildMenu.Show(treeView1, p);<br />
break;<br />
}<br />
<br />
treeView1.SelectedNode = m_OldSelectNode;<br />
m_OldSelectNode = null;<br />
if (node.Text.Equals("Credit Files"))<br />
{<br />
label1.Text = "Weekly Processes";<br />
}<br />
else if (node.Text.Equals("Human Resources"))<br />
{<br />
label1.Text = "Daily Process";<br />
}<br />
}<br />
}<br />
}<br />
<br />
}
each child node has a different set of properties which have to be set...i presume that for each child node we need a different panel.
also u have mentioned about some UserControls in one panel....i did not get that. Can u plz throw some more light on it?
waiting for your reply...
Sonu
|
|
|
|
|
Sonu.T wrote: about some UserControls in one panel
You could have separate UserControls instead of separate panels (Right click on Project in Solution Explorer -> Select Add -> UserControl). That way, each of your "panels" will be separate entities at design time. If you put everything in panels directly, then the main form holding all the panels would be congested with controls from different panels (when designing the UI from Visual Studio).
So you could have one panel to the right of the splitter and UserControl derived class for each of your screens. You could then load the appropriate control depending on the node selected in the tree. Something like
TreeNode selectedNode = ...;
switch(selectedNode.Text)
{
case "Weekly Processes";
panel.Controls.Clear();
panel.Controls.Add(weeklyProcessesControl);
break;
...
}
where panel is the System.Windows.Forms.Panel to the right of the splitter and weeklyProcessesControl is the usercontrol.
|
|
|
|
|
can I declare a variable, set it to a name of a form
then show it.
string a = "frm1";
form f = new a
f.show
help me
|
|
|
|
|
i don't know the exact solution but i use
if( a == "frm1")
{
form f = new a
f.show
}
|
|
|
|
|
Why do you want to do something like this? If all you want is to set the name of form, you could as well do
Form f = new YourForm();
f.Name = "frm1";
f.Show();
If frm1 is the name of the System.Windows.Forms.Form derived type and you want to instantiate it dynamically, you can do something like
string formTypeName = "frm1";
Type formType = Type.GetType(formTypeName);
Form f = (Form)Activator.CreateInstance(formType);
f.Show();
|
|
|
|