|
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.
|
|
|
|
|
I am hoping to switch tack from IT support (Lotus Admin & PC Analyst) to a C# development role and need a project to get my teeth into as most of the junior developer positions want at least personal project experience.
I have been studying the .Net framework for the last 2 years and have only really written code for examples in the self paced training course i am almost finished with (MS exam 70 532)
I am familiar with lots of the fundamental concepts but have no real idea of what i can do with them. I would like to work on a project that creates a useful windows form application that will give me good experience of the common elements of a c# application.
I know its a very vague question but any pointers on where to start or suggestions would be gratefully received. I would particularly welcome example of other peoples first projects.
|
|
|
|
|
This might not be the right forum but I will still answer it.
I was also in the same situation as you are. Started of as a system/network admin in my initial job and then moved on to c#.
The first program I created was a calculator, it seemed easy but I learnt a lot of things.
Since I had knowledge about system and network adminstration, my next project was a network status utility. The initial version just checked if a pc/server in the network was switched on or not. In the 2nd version I made it automatically detect pc's in a network instead of me manually adding it, it had a screen which showed a green icon with the pc name to indicate it was switched on and a red icon to indicate it was switched off. I also had different icons for the pc, server and the routers. In the 3rd version I used WMI to fetch details about the machine. It could get the event viewer details and a lot more.
A lot of network utilities existed in the market when I did this. My main intention was to learn c# and doing this particular project made me learn a lot about .net. I touched every major class in .net with this project.
I would suggest you do a project with a domain you are strong with. That way you concentrate more on the learning part rather than trying to understand how the sytem should work. As a pc anaylst think about something you used daily or wanted to have.
Tarakeshwar Reddy
There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group; there is less competition there. - Indira Gandhi
|
|
|
|
|
Two great suggestions thanks. I think i will start with a calculator, Following that I could do with a basic file monitor . We have an issue with something putting strange entries into a lotus config file i would really like to find the culprit. Where do i start with something like that?
Thanks for you help.
|
|
|
|
|
PROPZ_76 wrote: We have an issue with something putting strange entries into a lotus config file i would really like to find the culprit.
I would guess, that the lotus application is the one writing out the enteries to the config file. If that is the case, try to find out if Lotus has an SDK for the application you are working on and if the API has a method which allows you to listen to the config file change events.
Also, in .net you have ways to monitor a file and find out when it gets modified and which user has modified it. I am not sure if that would be of any help for you.
modified on Thursday, April 15, 2010 12:43 PM
Thanks Luc for pointing it out. The FileSystemWatcher cannot say which user had modified a file. I remember using the current user logged on to find out who might have changed the file. This might not work if you have a single administrator/user log on to the machine.
As I said, FileSytemWatcher might not be a very useful feature but just wanted to let you know that .net has a FileSystemWatcher class
Tarakeshwar Reddy
There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group; there is less competition there. - Indira Gandhi
modified on Thursday, April 15, 2010 12:43 PM
|
|
|
|