|
Ladies & Gentlemen
I have two issues when dealing with windows forms data binding.
1-I have created a windows form . And on it I have added tab control which has other controls .
I f I create a method to clear all controls on the form of data. Only controls on the tab that has focus are cleared of data. others remain uncleared and especially ComboBoxes.
How can I write a method to clear my form after data entry.
2-Second issue ,I have employee details. I have Banks and Each bank has branches. I want to create ComboBox that list all Banks and this should be linked to Branches ComboBox and the branches comboxBox should have its SelectedValue pointed to employee data row. That is it should make the look up table containing bank branches form employee data.
Meaning that if an employee has his account with ABC bank ,it should also specify the branch. That is I have a list of branches for each bank.
How can I implement this lookup hierarchy.
Amour Rashid Hamad
P.O.Box 9294
Directorate Of Information Services (TTCL)
Dar Es Salaam
Tanzania
|
|
|
|
|
Hi
How i can retrive an resource (Bitmap for handle) from my project.Before now i handn't experince with .Net resorces
and i anticipate this in the same way like in MFC projects, but there is no resource files, and i just add my bitmap inderectly to project(Project->Add New Item->Bitmap)is it correct? .And now i want to get the bitmap ID from my code.
Where is a way to do so??
Thank.
|
|
|
|
|
|
Thank.
Oddly enough, i suppose using resorces in NET became more
simplest, but in oppositely it seems more complicated.
|
|
|
|
|
no not really, the only importand thing is:
ResourceManager rm = new ResourceManager("app", this.GetType().Assembly);<br />
<br />
rm.GetObject( "keyname" );<br />
rm.GetString( "keyname" );<br />
no big deal - for editing resources u can use Resourcer[^]
|
|
|
|
|
In .NET 2.0, it's become even easier:
Image myImage = Properties.Resources.arrow;
Any remotely useful information on my blog will be removed immediately.
Judah Himango
|
|
|
|
|
Hi,
is it possible to set a row fixed under the header of a column so when i scoll it's always on top too?
if tried some overrides but i don't really know where to begin? Changing things like the scrollbar values don't fix the row on the top.
Any ideas?
|
|
|
|
|
Hi all
I have developed a com interop application in C#, its output is .dll.
It is working fine in the workstation (win XP)
Now I wand manually (Again Manually) deploy the same DLL in windows 2003 server, the server already has .net Framework,Can any one tell me how to deplay the com interop DLL?
More over I am integrating the C# DLL with a VC++ (Version 6) Client, the client will read the CLSID from the registry and create the instance of the .net component.In this case can any one guide me that how to deploy the interop component?
Thanks
|
|
|
|
|
|
I have a custom class within my code and I place multiple instances of this class into an ArrayList. At certain points in the code I would like to check if an instance of an object already exists in the array (not really an instance as such, more an object with the same values).
Now this doesnt work, I am certain that I am expecting far to much from the .Contains() function - so if anybody has any guidance on another solution please post it up.
As an example of the "problem" :
The following code returns false
private bool TestMe()
{
testClass tc1 = new testClass("abc", "def", "ghi");
testClass tc2 = new testClass("123", "456", "789");
testClass tc3 = new testClass("xxx", "yyy", "zzz");
testClass tc4 = new testClass("abc", "def", "ghi");
ArrayList array1 = new ArrayList();
array1.Add(tc1);
array1.Add(tc2);
array1.Add(tc3);
return array1.Contains(tc4);
}
The code above uses the following class
internal class testClass
{
public string abc;
public string def;
public string ghi;
public testClass(string abc, string def, string ghi)
{
this.abc = abc;
this.def = def;
this.ghi = ghi;
}
}
But interestingly this returns true
private void TestMe2()
{
string tc1 = "abc";
string tc2 = "123";
string tc3 = "xxx";
string tc4 = "abc";
ArrayList array1 = new ArrayList();
array1.Add(tc1);
array1.Add(tc2);
array1.Add(tc3);
return array1.Contains(tc4);
}
I assume that it works with basic types but not anything custom
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
use this test class and it will work:
internal class testClass
{
public string abc;
public string def;
public string ghi;´
public testClass(string abc, string def, string ghi)
{
this.abc = abc;
this.def = def,
this.ghi = ghi;
}
public override bool Equals(object obj)
{
testClass t = obj as testClass;
if (t == null) return false;
return t.abc == this.abc && t.def == this.def && t.ghi == this.ghi;
}
}
|
|
|
|
|
Thats great it works a treat.
But one small question, when I implement the override Visual Studio gives me the following warning :
c:\_development\csharp\containstest\form1.cs(131,18): warning CS0659: 'ContainsTest.Form1.testClass' overrides Object.Equals(object o) but does not override Object.GetHashCode()
If I put in the default override for GetHashCode(), the warning is no longer shown :
public override int GetHashCode()
{
return base.GetHashCode ();
}
Why does VS need that default override?
Also would it be possible to somehow manipulate the override so that it performs case insensitive searches based on the value of a boolean parameter?
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
The reason for the warning from the compiler is simple, when two objects return true from the .Equals override, they should always return the same hashcode... in essence equality and equal hashes go hand in hand. Also, when overriding .Equals it is good practice to override the == and != operator.
for case-insensitive it should be pretty easy:
public override bool Equals(object obj)
{
testClass t = obj as testClass;
if (t == null) return false;
return t.abc.toLower() == this.abc.toLower() && t.def.toLower() == this.def.toLower() && t.ghi.toLower() == this.ghi.toLower();
}
Another way is to use a CaseInsensitiveComparer , which im sure can be found easily on MSDN.
|
|
|
|
|
My problem relates to the code below, and I cant understand why its happening. I have to use the int test as the values I declared do not work. If you add a watch to guid, amount or serial, the watch value says that these are out of scope, and as such, nothing is assigned to them. If however I add in the int test, and assign it (as shown below), the program works. Any ideas?
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
string guid = "a";
int amount = 1;
byte[] serial = {1};
int test;
test = guid.Length;
test = amount;
test = serial.Length;
amount = r.ReadInt32();
guid = r.ReadString();
serial = r.ReadBytes(32);
r.Close();
fs.Close();
|
|
|
|
|
didn't understand
toticow wrote:
If you add a watch to guid, amount or serial, the watch value says that these are out of scope
when are they out of scope? after u've assigned them, without the int test ?
there are no facts, only interpretations
|
|
|
|
|
I a list view control before removing item(s) I am prompting the user with a message box "if he really wants to delete the item(s)". If the answer is "YES" then the item(s) are removed. when the answer is "NO" then the item(s) are not removed as it should be; but the selected item(s) are not displayed as selected that is hot items with rectacle showing the selection effect. How to show that rectangle?
In another way is to send the LVM_SETHOTITEM message which will show the items as selected. But I don't know how to send a message in C#
|
|
|
|
|
eDip wrote:
In another way is to send the LVM_SETHOTITEM message which will show the items as selected. But I don't know how to send a message in C#
Try the following:
int LVM_SETHOTITEM = 0x103C;
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, IntPtr lParam);
SendMessage(lvwCtrl.Handle, LVM_SETHOTITEM, index - 1, 0);
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi guys,
I want to ask how to call an external app from C# (a command like Shell command in VB.Net or ShellExcute in VC++).
Thank your.
|
|
|
|
|
|
Thank you for your answer. I had tried and ok. But I want still to know a command in C#, with functionality as Shell or ShellExcute command. Is there a such function in C#? and if yes, What is this? Could you tell me. Thank you very much
|
|
|
|
|
I'm pretty sure, there is not, but the combination of Process and ProcessStartInfo classes should provide everything to customize the startup of an exeternal program.
If not, try to p\invoke the ShellExecute method.
www.troschuetz.de
|
|
|
|
|
I'm trying to remove some items from a listbox but always get failed.
Assume one listbox item's text is "ItemText", value is "New", and index is 1.
I tried the following code to remove this item from a listbox:
ListBox.Items.Remove("ItemText");
Nothing happened after I run this code.
But when I used this: ListBox.Items.RemoveAt(1);
Then this item was removed.
Now I'm in a situation that I cannot get the index of a certain item. Then how can I remove this item if I only know it's text?
Thank you for your help!;)
|
|
|
|
|
You can check if an item is present by using the method Contains.
if (myListBox.Items.Contains(targetObject))
{
//then do something
}
You can get the index of a particular item by using the IndexOf method:
myListBox.Items.RemoveAt(myListBox.Items.IndexOf("ItemText"))
Also, here is some uncalled for advice: When you are deleting multiple rows in the listbox, start deleting items from the bottom.
Cheers
~/sathishvj
|
|
|
|
|
Thank you for your reply;).
I tried Items.IndexOf("ItemText") but the argument of indexof() must be a listitem but not a string or an integer.
Now I find I could make it in this way:
ListItem myitem = new ListItem("ItemText", "ItemValue");
myListBox.Items.Remove(myitem);
That could solve my current problem.
But if I couldn't get the value of t;)he item then I still can not remove it.
|
|
|
|
|
You can always get the index of a ListItem. Try using:
int itemIndex=listBox.FindStringExact("ItemText");
if (itemIndex>-1)
{
listBox.Items.RemoveAt(itemIndex);
}
|
|
|
|