hi everyone...
i got 2 questions:
1) can i display the datagrid in my program in a better way ..cuz what I've seen that it displays it like a table in the database
2) I've used the listbox and i would like to clear the items displayed in it....for an example i have a button search which will search in the database then displays the result in the listbox....and i have a button Clear which should clear the listbox....so how can i Clear the listbox
thanx...
bye

2 questions...?
SpyMark
thanx for helping me Yogesh Prabhu
the clearing worked ok with me
and about the girdview ...well iam thinking of displaying it in a listbox
i have plz another question ...about datetime
i know how to display it by using
System.DateTime.Now.ToLongTimeString()
but the problem is that it doesn't keep ticking ...it just displays it
i would like it to keep ticking and working ..like the timer of the windows
so how can i do it
thanx again...
C#Chris
To display a dropdown in GridView take a look at sample code in docs:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridviewcomboboxcolumn(VS.80).aspx
Here's a list of various column types supported by GridView:
http://msdn2.microsoft.com/en-us/library/bxt3k60s(VS.80).aspx
You need to add Timer component (available under Components in ToolBox). To update your time display every second, set timer's interval to 1000. Interval is measured in milliseconds. Set Enabled property to true, and finally handle its Tick event, and call the code you mentioned above. Here's sample of how to use Timer:
http://msdn2.microsoft.com/en-us/library/3tszykws(VS.80).aspx
Factor
thanx agian for helping me
but iam still facing a problem with the timer
here is the code i've written ...and tell me plz what's wrong
first i've include in the top of my program
using
System.Timers;then..
namespace
log_in{
public partial class login_form : Form{
public login_form(){
InitializeComponent();
}
private void InitializeTimer(){
//' Run this procedure in an appropriate event. // Set to 1 second.timer1.Interval = 1000;
// Enable timer.timer1.Enabled =
true;}
private void timer1_Tick(object sender, EventArgs e){
label7.Text =
DateTime.Now.ToString();}
when i run this code it's displays in the form "label7"
thanx...
Kevin Cogger MSFT
I believe you are referring to GridView when you mentioned DataGrid. If "better way" mean displaying dropdowns, checkboxes etc then it is possible. Please give us a specific scenario to help you with a code sample.
To clear items in the listbox you can use: yourListBoxName.Items.Clear() method.
TimurM
You have written a method to initialize the timer InitializeTimer() but did not call it anywhere. After InitializeComponents() type in following code:
if (!DesignMode)
InitializeTimer();