|
|
hey Glen.
Thanks for the reply.
I will try the same. However, it would look ugly to have empty rows when one is filtering. Still worth a shot.
Alternatively, I am trying the same with a data grid as well.
keshav
|
|
|
|
|
Instead of managing the listbox's items directly, you can databind the listbox to a list[string]. You can maintain a Dictionary[string, list[string]] that keeps track of all the views you want to show, then bind the listbox to the corresponding list<string>. Like this:
namespace ListBoxTest
{
public partial class ListBoxDataBinding : Form
{
Dictionary[string, List[string]] myLists = new Dictionary[string, List[string]]();
public ListBoxDataBinding()
{
InitializeComponent();
// Create a list of colors and add it to the dictionary
List[string] colors = new List[string]();
colors.Add("red");
colors.Add("green");
colors.Add("blue");
myLists.Add("colors", colors);
// Create a list of flavors and add it to the dictionary
List[string] flavors = new List[string]();
flavors.Add("vanilla");
flavors.Add("chocolate");
flavors.Add("strawberry");
myLists.Add("flavors", flavors);
}
// The user clicked the button that will cause the listbox to show flavors
private void btnFlavors_Click(object sender, EventArgs e)
{
// bind the listbox to the list of flavors
this.filteredListBox.DataSource = this.myLists["flavors"];
}
// The user clicked the button that will cause the listbox to show colors
private void btnColors_Click(object sender, EventArgs e)
{
// bind the listbox to the list of colors
this.filteredListBox.DataSource = this.myLists["colors"];
}
}
}
Just an idea.
BTW, when using the generic List and Dictionary types, you'll need to replace the '[' and ']' with '<' and '>'. Anyone know how to escape the '<>' characters?
Ian
|
|
|
|
|
Hey thanks Ian,
I really appreciate it man.
Keshav
|
|
|
|
|
Hi,
Sorry for my ignorance...
I need to retrieve values (decimals) from a DataTable. What is the difference between these two methods of converting the object to a decimal and which one is best? Is there another way of retrieving decimals and keeping their native format?
A: decimal labelWidth = Convert.ToDecimal(myDataTable.Rows[0]["LabelWidth"]);
B: decimal labelWidth = (Decimal)myDataTable.Rows[0]["LabelWidth"];
Ron
|
|
|
|
|
(a) They are both the same and (b) If you make labelWidth an object then you don't need to do a conversion to decimal at that time.
object labelWidth = myDataTable.Rows[0]["LabelWidth"];
Never apologise for your ignorance - we all have it
Glen Harvy
|
|
|
|
|
|
Hi,
In a game I'm writing, I have 2 main meshes: Landscape and house. The landscape is where the player walks and the house is where he lives. The house is every detailed with stairs, doors and all other stuff.
Problem:
My problem is that the character simple walks through the walls and doors and I cannot climb the stair.
Can someone please help me with the code on collision detection so that I will not walk through walls, the logic for opening the door and how to implement the climbing of stairs
I'm using Artificial Engine but it has exposed the directx classes for any help in direct x will be very helpful.
Thank you
|
|
|
|
|
Hy,
Error mesaj: Object cannot be cast from DBNull to other types
Localhost everything works fine, but when i pput my works online, when i try to add a user i take this mesaj of error here: Object cannot be cast from DBNull to other types
Thanks
|
|
|
|
|
What is the relevant code at the point of failure?
|
|
|
|
|
As a guess, your "online" datatable is empty.
Glen Harvy
|
|
|
|
|
while inserting a new row in your db you must be forgetting Value of a Non Empty field(Allow Null=false).
please check it
|
|
|
|
|
I check this but all my field have Allow Null=false.
I realy don;t know what hapen because like i said before localhost is ok, but online isn't
I accept any sugestion
Thancks
|
|
|
|
|
this is the eror
Object cannot be cast from DBNull to other types.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Object cannot be cast from DBNull to other types.
|
|
|
|
|
Another newbie needing help....
I need to 2 radio (or text) buttons so that both cannot be on at the same time.
<br />
private void radioButton1_CheckedChanged(object sender, EventArgs e)<br />
{<br />
radioButton2.Checked = false;<br />
}<br />
<br />
private void radioButton2_CheckedChanged(object sender, EventArgs e)<br />
{<br />
radioButton1.Checked = false;<br />
}<br />
But it doesn't work when I have
On radioButton1
OFF radioButton2
and when I click on radioButton2, radio button1 goes off but radiobutton2 also remains off.
Do I have a circular event?
|
|
|
|
|
Hi,
1.
if one rb is checked, and for some reason gets unchecked, then you also uncheck the
other, hence both will be unchecked, which is NOT what you want.
2.
no this is not circular, since a "changed" event only fires when the value CHANGES,
not when a value gets assigned that equals the current value.
3.
If you put your rb's in a GroupBox, then they behave like real rb's automatically
(at most one checked).
|
|
|
|
|
The CheckedChanged event is raised when the radio button is checked or unchecked. The problem with your code above is that: Assuming 1 was previously checked
when 2 is clicked, a checkedchanged for 2 is raised,which unchecked 1
this raises checkedchanged for 1 which also disables 2. At such both are disable
(The scenario above assumes that the control are in different containers)
You could use this code
<code>private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
radioButton2.Checked = !radioButton1.Checked;
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
radioButton1.Checked = !radioButton2.Checked;
}</code>
|
|
|
|
|
the suggested solutions will work, even you can simplfy this by putting both the radio buttons in Group box and there is no need to write any code. group box itself will take care these logic
|
|
|
|
|
Is it possible for multiple instances of the same service to be running simultaneously?
If so, is there a way that you can check to see if the service is already running and stop the second instance from starting up?
|
|
|
|
|
No I dont think so, services need unique names.
If you WANT the same service twice, use different names.
|
|
|
|
|
New to C#
And I have a project addressing broadcasting stations. Somehow I have to activate a server that will sent a flux read by the user's real player plugin. I was able to activate thru a form and a button, to have the form webbrowser read a html file in which I have and embeded command that selects and open the right radio station. That html file is accompanied with an xml css file to have a little "look and feel" on the tiny webbrowser. The whole thing works ok, but I have to store 3 files accompaning my exe file. To my taste this is too much files. Most broadcast radioswidgets have only one exe file.
Please have you an idea how to consolidate all this ? One of my exe radio widget offered by the Radio stations seems to be recognized by my firewall protection when I activate it as a macromedia flash player although it is a an exe appli.
Last is there Html in commands in C#, or how can I activate flash plugins.
To Sum it:
1: Consolidating files
2: Activating flash file
3: Local C# Html commands
Thanks for any help
If you dont know were you are,look back were you come from. (Some time one dont know how far they travelled) Next time before you complain ! Give a friendly look to your sole. (African Wisdom).
|
|
|
|
|
Hi.
I have several datatables that each have the same structure. They represent individual bank accounts.
When the user selects the bank account and then saves the transaction I use the following code:
if (cbPayBillsWhichAccount.Text == "Administration Fund")<br />
{<br />
try<br />
{<br />
mybodycorpDataSet.AdminFundRow newRow = this.mybodycorpDataSet.AdminFund.NewAdminFundRow();<br />
<br />
if (this.dtpPayBillsTransactionDate.Text == string.Empty)<br />
{<br />
newRow.Date = DateTime.Today;<br />
}<br />
else<br />
{<br />
newRow.Date = Convert.ToDateTime(this.dtpPayBillsTransactionDate.Text);<br />
}<br />
<br />
newRow.Debit = true;<br />
newRow.ChequeNumber = this.tbPayBillsChequeNumber.Text.ToString();<br />
newRow.Payee = paySupplierName;<br />
newRow.Amount = Convert.ToDecimal(tbPayBillsHowMuch.Text);<br />
newRow.Reconciled = false;<br />
<br />
this.mybodycorpDataSet.AdminFund.Rows.Add(newRow);<br />
this.adminFundTableAdapter.Update(mybodycorpDataSet.AdminFund);<br />
}
What I wish to do is re-use the code (essentially all the "newRow" lines) as ammended for each chosen bank account.
How would you suggest I go about this?
Glen Harvy
|
|
|
|
|
Which of the following is better? And why?
public void DoSomething(bool status)<br />
{<br />
status = false;<br />
<br />
...
<br />
if (everything is okay) status = true;<br />
}
or
public bool DoSomething()<br />
{<br />
...
<br />
if (everything is okay)<br />
return TRUE;<br />
else<br />
return FALSE;<br />
}
Brad
The secret to creativity is knowing how to hide your sources. - Albert Einstein
|
|
|
|
|
static void testThis(bool bValue)
{
bValue = false;
}
static int Main(string[] args)
{
bool myBool = true;
Console.WriteLine(myBool);
Console.WriteLine("Calling testThis()");
testThis(myBool);
Console.WriteLine(myBool);
Console.WriteLine("Did I learn anything?");
}
led mike
|
|
|
|
|
Brilliant response. Got my 5!
|
|
|
|