|
Please don't post to every forum on the site. This is a common piece of homework, and so I'm sure you could find some code with google, although it's pretty straightforward to write. ( Yes, I understand you're saying it's not homework, I'm saying the fact that it often is increases the odds of a snippet existing online )
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
What happened to sharing?
I know it is straight-forward and I know it is given as homework to university students, but also know it will waste my time since it only deals with the basic programming operations...I'm trying to avoid going deep into things that are easy and take up a lot of time and was wondering if somebody could help...Right now i'm swammed in datagrid lousy events and too much SQL problems, I'd rather stick my nose into something else...that's all...
|
|
|
|
|
Please send me your email i will send you an example numbers to letters. Ok
....
Muhamad Waqas Butt
waqasb4all@yahoo.com
|
|
|
|
|
|
ok All Right Buddy.....
Muhamad Waqas Butt
waqasb4all@yahoo.com
|
|
|
|
|
Hadi Fakhreddine wrote:
What happened to sharing?
What do you mean ?
Hadi Fakhreddine wrote:
but also know it will waste my time since it only deals with the basic programming operations...
I don't *have* an example here, I was just suggesting that you would find one easily. If I had one, I would have posted it. I see you followed my advice anyhow, and found an example online.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a nifty little application that doesnt have any fancy controls etc. embedded in it. However, when i run the program it uses up a whopping 16MB or RAM. I was expected something more on the lines of 2MB. How can i decrease the overhead?
|
|
|
|
|
Use C++
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Where did you see the 16MB value? TaskManager? Which column??
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I saw the value in the column labelled 'Mem Usage'. Is that the RAM usage? If not, which is the appropriate column to watch?
|
|
|
|
|
It doesn't really matter because you can't get rid of that footprint anyway.
Even though you see in Task Manager that your app is consuming 16MB of RAM, it doesn't mean that your actually using it. Since the .NET Framework execution environment is a virtual machine, the memory manager in the Framework RESERVES a chunk of memory for your app to use. (There's also the overhead of the .NET Framework too, so you're not going to be able to get rid of that!)
Your app isn't actually using that much memory. It's just there so you have a pool of MANAGED memory for your app to use. If you exceed this pool, the .NET memory manager will grab some more memory for the virtual machine. The opposite is also true. If Windows needs some of that memory back, and your app isn't using it, the .NET memory manager will drop a chunk of memory out of it's managed pool and release it back to the system.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a textbox on my form. Now, I want to find which key was pressed in the textbox. I mean i want to find which key pressed including Function keys F1, F2, etc...Modifier Keys like SHIFT, CTRL, and ALT. How can I do this.
|
|
|
|
|
I looked up on Google and I found a post on a forum that said taht you have to use the System.Threading.Thread.Sleep(int milliseconds). Howecer, when i do this the UI hangs. Basically, what I'm trying to accomplish here goes like this: I have a for loop and between loop iterations i wish to put a 5 second delay. Now what?
|
|
|
|
|
Mridang Agarwal wrote:
looked up on Google and I found a post on a forum that said taht you have to use the System.Threading.Thread.Sleep(int milliseconds).
Bizarre. This is a pile of bull. Why would you have to sleep to get a key event ? But good for you for trying to find the answer all the same.
Mridang Agarwal wrote:
I have a for loop and between loop iterations i wish to put a 5 second delay. Now what?
Oh, this is a different question ? Yes, Thread.Sleep is your answer, but it stops your app running, obviously. The other possibility is to put this code in a thread, so only that thread sleeps, or create a big old ugly loop that uses datetime.now over and over, and calls Application.DoEvents. Why do you want your app to sleep for 5 seconds ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Oh !#$#. What he hell did I just post? That was a big goof up. I was posting a reply to another post and I accidentally posted it here. Sorry!
|
|
|
|
|
If you catch the KeyPressed event, you get a different event args to KeyDown/KeyUp. There's another event for control keys as well, I think. You can also call GetAsyncKeyState via pinvoke, for full control over what control keys are down, etc, during any keyboard event, or anywhere in your code, for that matter.
KeyDown/KeyUp have the properties to say if a control key was pressed, KeyPressed actually gets a different key code ( in the range 0-25, I *think* ) if Control is also down.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
i got the solution finally. I put the in the textbox_KeyUp event and wrote e.Keydata.ToString();
|
|
|
|
|
You'll simply need to handle the "KeyDown" event of the TextBox like so:
Just put a similar code in the KeyDown event of the TextBox:
If e.KeyCode = Keys.Enter Then<br />
'Whatever you wanna do<br />
End If
The keys F1, F2, etc... are also present in the Keys enumeration (Keys.F1, Keys.Tab, Keys.a, etc...)
PEACE!
|
|
|
|
|
how are you my friend .
listen my friend about handling the keydown event is not useful and wasting time if you try to handle it through your keydown event handling cause you will need to nest alot alot of if statements and switch keywords and it is not practical you need something like keylogger code to log any keys pressed even if your form is activated or not then you can handle the specific key when it is pressed like the following code :-
<br />
<br />
<br />
system.Runtime.InteroServices;<br />
<br />
[Dllimport("User32.dll")]<br />
Public static extern short GetAsyncKeyState(System.Windows.forms.Keys vkey);<br />
[Dllimport("User32.dll")]<br />
public static extern short GetAsyncKeyState(System.Int32 vkeys);<br />
<br />
System.Timers.Timer mytimer;<br />
System.String KeyBuffer;<br />
<br />
Private void mytimer_Elapsed(object o , System.Timers.ElapsedEventargs args)<br />
{<br />
foreach(System.Int32 i in Enum.GetValues(typeof(Keys)))<br />
{<br />
if(GetAsyncKeyState(i) == -32767)<br />
{<br />
keybuffer += Enum.GetName(typeof(keys),i);<br />
TextBox.Text += KeyBuffer;<br />
Keybuffer = "";<br />
}<br />
}<br />
}<br />
public YourKeyLogger()<br />
{<br />
mytimer.Elapsed += new ElapsedEventHandler(this.mytimer_elapsed);<br />
}<br />
I hope the code can do the work for you
Thanks my friend
Miss With The Best And Die Like The Rest
|
|
|
|
|
I have a datatable that has an id, firstname, lastname, and email address field being returned. I also have a datagrid that has the datasource set to the datatable. I have hidden the id column by using:
oDataTable.Columns["id"].ColumnMapping = MappingType.Hidden
so that the id column doesn't display to the end user but is still available to reference. I am now trying to double click the row in the datagrid and get the hidden id column value in the double click event so that I can pass that value. How is the best practice to do this?
|
|
|
|
|
oDataTable.Rows[this.yourDataGrid.CurrentCell.RowNumber]["id"].ToString()
Live Life King Size
Alomgir Miah
|
|
|
|
|
Hi.
I have such a strange problem. I define class which is derived from System.Windows.Forms.UserControl and implements some interface.
public class ORAMainControl : System.Windows.Forms.UserControl, IORAPluginControl
Now when I try to derive any other control from this ORAMainControl, VisualStudio designer won't appear, saying that non of the classes can be designed.
Did some digging, and eventually changed declaration to ORAMainControl to this:
[Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL",
typeof(IRootDesigner)),
DesignerCategory("Form")]
public class ORAMainControl : System.Windows.Forms.UserControl, IORAPluginControl
Now when I attempt to design any derived class Stuido says that it can't find a designer for ORAMainControl.
Where I am wrong and what to do? I am stuck.
Thanks in advance.
|
|
|
|
|
hi,
i have a datagrid on a usercontrol which has two columns of DateTimePicker style. They are 'From Date' and 'To Date'.
when i enter data in the first row, then i also choose the date. So when i add data in the second row, the dateTimePicker in 'From Date ' Should show me the next day of the date that i entered in the 'To Date' of the previous column. This should happen for all the rows that i enter..
could ne1 plz tell me how to do this??
Any help is appreciated,
Thanks
|
|
|
|
|
using System;
using System.Data;
using System.Windows.Forms;
using System.Drawing;
namespace Test.Controls
{
///
/// Summary description for DataGridTimePickerColumn.
/// This class builds the DateTimePicker column user control for datagrids for windows application.
/// It inherits DataGridTextBoxColumn, since this is already an available control in the .Net Framework.
/// What needs to be modified, depending on the application, is the ValueChanged event.
/// To use this class, simply add it to the project, construct an instance, and use its properties.
/// this is a sample usage:
///
/// DataGridTimePickerColumn col3=new DataGridTimePickerColumn();
/// dataGrid1.TableStyles[0].GridColumnStyles.Add(col3);
/// dataGrid1.TableStyles[0].GridColumnStyles[7].MappingName="Date Time";
/// dataGrid1.TableStyles[0].GridColumnStyles[7].HeaderText="Date Time";
/// dataGrid1.TableStyles[0].GridColumnStyles[7].Width=100;
///
///
public class DataGridTimePickerColumn : DataGridTextBoxColumn//DataGridColumnStyle
{
private DateTimePicker myDateTimePicker = new DateTimePicker();
// The isEditing field tracks whether or not the user is
// editing data with the hosted control.
private bool isEditing;
public DataGridTimePickerColumn() : base()
{
myDateTimePicker.Visible = false;
}
protected override void Abort(int rowNum)
{
isEditing = false;
myDateTimePicker.ValueChanged -=
new EventHandler(TimePickerValueChanged);
Invalidate();
}
protected override bool Commit
(CurrencyManager dataSource, int rowNum)
{
myDateTimePicker.Bounds = Rectangle.Empty;
myDateTimePicker.ValueChanged -=
new EventHandler(TimePickerValueChanged);
if (!isEditing)
return true;
isEditing = false;
try
{
DateTime value = myDateTimePicker.Value;
SetColumnValueAtRow(dataSource, rowNum, value);
}
catch (Exception)
{
Abort(rowNum);
return false;
}
Invalidate();
return true;
}
protected override void Edit(
CurrencyManager source,
int rowNum,
Rectangle bounds,
bool readOnly,
string instantText,
bool cellIsVisible)
{
DateTime value = DateTime.Parse(GetColumnValueAtRow(source, rowNum).ToString());
if (cellIsVisible)
{
myDateTimePicker.Bounds = new Rectangle
(bounds.X + 2, bounds.Y + 2,
bounds.Width - 4, bounds.Height - 4);
myDateTimePicker.Value = value;
myDateTimePicker.Visible = true;
myDateTimePicker.ValueChanged +=
new EventHandler(TimePickerValueChanged);
}
else
{
myDateTimePicker.Value = value;
myDateTimePicker.Visible = false;
}
if (myDateTimePicker.Visible)
DataGridTableStyle.DataGrid.Invalidate(bounds);
}
protected override Size GetPreferredSize(
Graphics g,
object value)
{
return new Size(100, myDateTimePicker.PreferredHeight + 4);
}
protected override int GetMinimumHeight()
{
return myDateTimePicker.PreferredHeight + 4;
}
protected override int GetPreferredHeight(Graphics g,
object value)
{
return myDateTimePicker.PreferredHeight + 4;
}
protected override void Paint(Graphics g,
Rectangle bounds,
CurrencyManager source,
int rowNum)
{
Paint(g, bounds, source, rowNum, false);
}
protected override void Paint(
Graphics g,
Rectangle bounds,
CurrencyManager source,
int rowNum,
bool alignToRight)
{
Paint(
g,bounds,
source,
rowNum,
Brushes.Red,
Brushes.Blue,
alignToRight);
}
protected override void Paint(
Graphics g,
Rectangle bounds,
CurrencyManager source,
int rowNum,
Brush backBrush,
Brush foreBrush,
bool alignToRight)
{
DateTime date = DateTime.Parse(GetColumnValueAtRow(source, rowNum).ToString());
Rectangle rect = bounds;
g.FillRectangle(backBrush,rect);
rect.Offset(0, 2);
rect.Height -= 2;
g.DrawString(date.ToString("d"),
this.DataGridTableStyle.DataGrid.Font,
foreBrush, rect);
}
protected override void SetDataGridInColumn(DataGrid value)
{
base.SetDataGridInColumn(value);
if (myDateTimePicker.Parent != null)
{
myDateTimePicker.Parent.Controls.Remove
(myDateTimePicker);
}
if (value != null)
{
value.Controls.Add(myDateTimePicker);
}
}
private void TimePickerValueChanged(object sender, EventArgs e)
{
this.isEditing = true;
base.ColumnStartedEditing(myDateTimePicker);
}
}
}
Live Life King Size
Alomgir Miah
|
|
|
|
|
HEY! Thanks..but i've already written that code..it is to use a datatmepicker in a datagrid...but u dinn get what i asked...i wld appreciate if u cld help me...
i have a datagrid on a usercontrol which has two columns of DateTimePicker style. They are 'From Date' and 'To Date'.
when i enter data in the first row, i select the date in the two columns. So when i add data in the second row, the dateTimePicker in 'From Date ' Should show me the next day of the date that i entered in the 'To Date' of the previous column. This should happen for all the rows that i enter..
plz tell me how to do this..
|
|
|
|
|