|
sri_0099 wrote: Yes, i set the parent form as property. And before closing childform i called prentform.activate() method.
The parent isn't always the owner.
There's an overloaded version of the .Show and .ShowDialog method that takes an Owner-handle. The OS will reset the focus to this "owner" if the window gets closed. Something like this;
new MyForm.Show(this); If all is well, then you should be able to remove the ParentForm.Activate(), just closing the child should be enough.
I are Troll
|
|
|
|
|
I have a Forms Application which I have just added the MothCalendar control too and I am ubale to change any of the properties, such as BackGroundColor, Size, etc.
I have tried using the designer and in code but the interface does not change!
Is there a trick to using this control?
Thanks
|
|
|
|
|
Probably because there is no control called as MothCalendar
On serious note, MonthCalendar cannot be modified while you are using Visual Styles for the control. You need to disable the visual styles and Month Calendar will respond to your modifications.
If you do not want to switch off visual styles for the complete application, extend the MonthCalendar class and then disable the visual styles for a that class. Then you can use this new control on your forms.
|
|
|
|
|
Okay call me dumb!!!! dahhh....
Thansk for the suggestion. I do have one other question for you... Where do I turn on/off "Visual Styles" for the MoNthCalendar? It is not in the controls properties where else should I be looking?
|
|
|
|
|
Squire Dude wrote: Okay call me dumb!!!! dahhh....
Its ok buddy... it just brought a good smile on both our faces. So fine.
There are two things that you can do.
1. As mentioned above, you can extend the class. Here is a class that does the job:
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace EZ
{
public class EZMonthCalendarControl : MonthCalendar
{
[DllImportAttribute("uxtheme.dll")]
private static extern int SetWindowTheme(IntPtr hWnd, string appname, string idlist);
protected override void OnHandleCreated(EventArgs e)
{
SetWindowTheme(this.Handle, "", "");
base.OnHandleCreated(e);
}
private void InitializeComponent()
{
this.SuspendLayout();
this.ResumeLayout(false);
}
}
}
2. You can disable the theme in the Main funtion in Program.cs. Just remove the line EnableVisualStyles(). But this will cause the visual style to be disabled for the whole of the application.
Cheers.
|
|
|
|
|
Thanks for the ideas and suggestion and code...
First I tried your second suggestion... turing off VisualStyles... and id does kind of mess things up on other forms. Then I looked at your code and it looed simple enough!
I have never put a wrapper around a class before as in you first suggestion. How do I apply the code?
|
|
|
|
|
Squire Dude wrote: How do I apply the code?
1. Add a new class into your project, replace content with the code i provided.
2. compile the project once
3. instead of dropping the month calendar. drop this new control on your form.
|
|
|
|
|
Now I am feeling really dumb!!!!
I got through parts 1 & 2 but how do I "Drop" the new control on the form?
I tried makeing a User Control & a Class with your code replacing the generic code. I ran Build... But if I try to drag & drop the file onto the form it will not stick.
What am I missing???
|
|
|
|
|
google: how to use custom user controls on c# forms.
this is the first link: click here
|
|
|
|
|
Thanks for the pointer. I could not get any of the links to work but did start reading the text further down the page... I am not sure how it realates to what I was asking? Maybe I am just having very dumb day as I could not see how it related what I am trying to accomplish. But thanks anyway for your time and assistance.
|
|
|
|
|
well, since you are creating your custom control within your project, it should be available in the toolbar at the very top. Above "All Windows Controls".
|
|
|
|
|
Okay my bad.... I had a big case of Brain Fade yesterday now I hope that it is behind me and I can move forward today.... so far so good!
I appologise for not getting it... You are correct of course the new Control is on the Left (Controls) pane and can be dragged onto a form etc.
Thank you for your patience and sticking with me I really do appreaciate the effort.
Thanks
SquireDude
|
|
|
|
|
Happens... Everyone has day like that
|
|
|
|
|
I have just tested the MothCalendar control after seeing your question.
I am able to change most of the properties (haven't checked them all) except for the Size, by normal means anyway, although BackColor and most others are OK. To overcome this size limitation I have found a work around:
1) Change the Font size. Not exactly precise but it works.
MonthCalendars' size is controlled because it would look really silly with an enormous control and all the data squashed up in one corner.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I have a simple list box that contains some string values. This list box is initially populated by binding to a collection (via DataSource field). However later user will be able to add some values into it also. When I just do a listbox.Items.Add(mystring), this new values never show up in the listbox itself. Any ideas what I am doing wrong? Or may be there are standard patterns for dealing with this type of situation?
|
|
|
|
|
When bindigng to a collenction, you have to add the
item to the collection not the listbox.Items.
Watch out for Exceptions!!!
listBox1.DataSource = yourListOrCollection;
listBox1.DataSource=null;
yourListOrCollection.Add("Something");
listBox.DataSource = yourListOrCollection;
|
|
|
|
|
Thanks for the reply. Problem is that my collection is actually an entity collection that is returning bunch of columns from table and I am just using one of the column to populate this listbox. I therefore not sure if I can add this item into the collection.
|
|
|
|
|
sure there is.
nothing is impossible.
You could trick/force something like that in many ways.
0) Add a whole item to the collection with default/empty values for the not used cols(delete them after words)
1) Createa a separate array or list of strings from that column
...
|
|
|
|
|
Got it. Its working for me now.
Thanks for your help
|
|
|
|
|
|
Is there a place in the Registry or somewhere, archived, that stores the window dimensions of Microsoft Office applications, specifically Access 2007?
I want to access the Height and Width (possibly location) of the last used instance of Access 2007 and then be able to set those "variables" so that I can restore the dimensions I choose.
Thank you,
JJ
|
|
|
|
|
sorry for breach in Forum-etiquette:
I believe i found what registry values I am looking for under,
HKEY_CURRENT_USER
\Software\Microsoft\Office\12.0\Access\Settings
I will leave this up for a while in case there is any interest
|
|
|
|
|
Hi,
on CodeProject users are not expected to remove anything. The forums can and will be searched by many others, who will be happy to find what they need.
|
|
|
|
|
here i am pasting my code now i want that behind this datagrid i want to show some text that should be visible throw the datagrid and that text may be a only text or any label's text behind the datagrid.
so want my datagrid as transparent but i have tried. but not succeeded.
please help.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class CheckItem : Form
{
public CheckItem()
{
InitializeComponent();
}
private DataTable Item = new DataTable("CheckItem");
private Label lbl = new Label();
private Label lbl5 = new Label();
//To drag The Form Without Border
#region"To drag The Form Without Border"
const int WM_NCHITTEST = 0x84;
const int HTCLIENT = 0x1;
const int HTCAPTION = 0x2;
protected override void WndProc(ref System.Windows.Forms.Message m)
{
switch (m.Msg)
{
case WM_NCHITTEST:
base.WndProc(ref m);
if (m.Result.ToInt32() == HTCLIENT) m.Result = new IntPtr(HTCAPTION);
break;
default:
base.WndProc(ref m);
break;
}
}
#endregion
#region"private void CheckItem_Load"
private void CheckItem_Load(object sender, EventArgs e)
{
try
{
//Fixing the length and position of windows form.
Screen scr = Screen.PrimaryScreen;
//this.Left = (scr.WorkingArea.Width - this.Width) / 2;
//this.Top = (scr.WorkingArea.Height - this.Height) / 2;
this.MaximumSize = new Size(this.Width, this.Height);
this.MinimumSize = new Size(this.Width, this.Height);
// Label
#region"Label"
DataGridTableStyle dgStyle = new DataGridTableStyle();
dgStyle.HeaderBackColor = Color.Chocolate;
dgStyle.HeaderForeColor = Color.White;
dgStyle.HeaderFont = new Font("verdana", 8, FontStyle.Bold);
DataGridTextBoxColumn dgItemCode = new DataGridTextBoxColumn();
dgItemCode.ReadOnly = true;
dgItemCode.Width = 80;
DataGridTextBoxColumn dgItemName = new DataGridTextBoxColumn();
dgItemName.ReadOnly = true;
dgItemName.Width = 90;
DataGridTextBoxColumn dgRecivedQuantity = new DataGridTextBoxColumn();
dgRecivedQuantity.ReadOnly = true;
dgRecivedQuantity.Width = 130;
DataGridTextBoxColumn dgApproved = new DataGridTextBoxColumn();
dgApproved.Width = 80;
DataGridTextBoxColumn dgRejected = new DataGridTextBoxColumn();
dgRejected.Width = 80;
dgItemCode.HeaderText = "Item Code";
dgItemCode.MappingName = "ItemCode";
dgItemName.HeaderText = "Item Name";
dgItemName.MappingName = "ItemName";
dgRecivedQuantity.HeaderText = "Recived Quantity";
dgRecivedQuantity.MappingName = "RecivedQuantity";
dgApproved.HeaderText = "Approved";
dgApproved.MappingName = "Approved";
dgRejected.HeaderText = "Rejected";
dgRejected.MappingName = "Rejected";
#endregion
// Create temprarory datatable
#region"Create temprarory datatable"
DataTable Item = new DataTable();
DataRow dr;
Item.Columns.Add("ItemCode", typeof(string));
Item.Columns.Add("ItemName", typeof(string));
Item.Columns.Add("RecivedQuantity", typeof(Int32));
Item.Columns.Add("Approved", typeof(Int32));
Item.Columns.Add("Rejected", typeof(Int32));
//Add temp datas
dr = Item.NewRow();
dr["ItemCode"] = "I007";
dr["ItemName"] = "RAM";
dr["RecivedQuantity"] = 1344;
dr["Approved"] = 904;
dr["Rejected"] = 220;
Item.Rows.Add(dr);
dr = Item.NewRow();
dr["ItemCode"] = "I004";
dr["ItemName"] = "RM";
dr["RecivedQuantity"] = 10;
dr["Approved"] = 900;
dr["Rejected"] = 200;
Item.Rows.Add(dr);
dr = Item.NewRow();
dr["ItemCode"] = "I006";
dr["ItemName"] = "RAM";
dr["RecivedQuantity"] = 1000;
dr["Approved"] = 900;
dr["Rejected"] = 200;
Item.Rows.Add(dr);
#endregion
//Adding Label
#region"Adding Label"
Label lbl1 = new Label();
lbl1.Font = new Font("Verdana", 8, FontStyle.Bold);
lbl1.BackColor = Color.White;
lbl1.Left = 50;
lbl1.Text = " ";
lbl1.ForeColor = Color.White;
Label lbl2 = new Label();
lbl2.Font = new Font("Verdana", 8, FontStyle.Bold);
lbl2.Left = 50;
lbl2.Text = " ";
lbl2.ForeColor = Color.White;
Label lbl3 = new Label();
lbl3.Font = new Font("Verdana", 8, FontStyle.Bold);
lbl3.Left = 50;
lbl3.Text = " ";
lbl3.ForeColor = Color.White;
//Label lbl = new Label();
lbl.Font = new Font("Verdana", 8, FontStyle.Bold);
lbl.Text = "*";
lbl.Left = 50;
lbl.ForeColor = Color.Red;
//Label lbl5= new Label();
lbl5.Font = new Font("Verdana", 8, FontStyle.Bold);
lbl5.Text = "*";
lbl5.Left = 50;
lbl5.ForeColor = Color.Red;
dgItemCode.TextBox.Controls.Add(lbl1);
dgApproved.TextBox.Controls.Add(lbl);
dgRejected.TextBox.Controls.Add(lbl5);
dgItemName.TextBox.Controls.Add(lbl2);
dgRecivedQuantity.TextBox.Controls.Add(lbl3);
dgStyle.GridColumnStyles.Add(dgItemCode);
dgStyle.GridColumnStyles.Add(dgItemName);
dgStyle.GridColumnStyles.Add(dgRecivedQuantity);
dgStyle.GridColumnStyles.Add(dgApproved);
dgStyle.GridColumnStyles.Add(dgRejected);
#endregion
dgStyle.PreferredRowHeight = 24;
dataGrid1.TableStyles.Add(dgStyle);
//binding datagrid
dataGrid1.BackColor = Color.Transparent;
dataGrid1.CaptionText = "Check Item";
dataGrid1.DataSource = Item;
//code for combox on pageload event
cmbPurchaseOrder.SelectedIndex = 0;
cmbVender.SelectedIndex = 0;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region"private void btnReset_Click"
private void btnReset_Click(object sender, EventArgs e)
{
cmbPurchaseOrder.SelectedIndex = 0;
cmbVender.SelectedIndex = 0;
BillOfMaterial frm = new BillOfMaterial();
frm.Show();
}
#endregion
#region"private void btnCancel_Click"
private void btnCancel_Click(object sender, EventArgs e)
{
this.Dispose();
}
#endregion
private void CheckItem_MouseMove(object sender, MouseEventArgs e)
{
lbl.Text = "*";
lbl.Font = new Font("Verdana", 8, FontStyle.Bold);
lbl.Text = "*";
lbl.Left = 50;
lbl.ForeColor = Color.Red;
lbl5.Font = new Font("Verdana", 8, FontStyle.Bold);
lbl5.Text = "*";
lbl5.Left = 50;
lbl5.ForeColor = Color.Red;
}
}
}
|
|
|
|
|
I hate to tell you this, but you cannot do what you want to do with the standard controls in the ToolBox.
Transparent is not really transparent. When you set the BackColor of a control to Transparent, you're really telling the control to take on the background properties of the controls parent container. You will NOT be able to see any controls sitting behind the DGV.
You cannot achieve what you want without custom drawing the DGV. That's not something that I want to think about, let alone do.
I think your best shot at success with this would be to implement this in a WPF app, not Windows Forms.
|
|
|
|