|
TCPMem wrote: Is there some kind of a rule where global variables should have "_" before their names
No there is no some kind of rule where global variables should have "_".
"_" is one of the symbol which can be used defining variable name.
you need to only follow the standard rule made for declaring Variable Name.
|
|
|
|
|
I have a Windows Forms ListBox object showing items that originate in a dictionary.
To apply different coloring etc to some of the entries I have set
dropDownListBox.DrawMode = DrawMode.OwnerDrawFixed
and handling the listbox DrawItem and MeasureItem events.
The different colored items are basically additional choices or items I add or remove depending on other factors.
These are commands if you like eg. "Advanced Filter", "Remove This Filter" etc and always appear at the top of the listbox items, and are highlighted to separate them from the normal data values.
When I show the listbox I set the dropDownListBox.SelectedItem to the previously selected item which may be well down the list.
I would like to be able to "freeze" the required top row(s) or commands eg "Advanced Filter", so that as I scroll down, or the listbox shows with the previously selected item, the required rows are always visible.
This would save scrolling back right back to the start to select "Advanced Filter".
Not having much joy so far, can anyone assist?
Thanks
AussieLew
DrawItem and MeasureItem handlers below...
void dropDownListBox_DrawItem(object sender, DrawItemEventArgs e)
{
Brush myBrush = Brushes.Green;
Brush backBrush = Brushes.Red;
string listString = dropDownListBox.Items[e.Index].ToString();
e.DrawBackground();
switch (listString)
{
case "Advanced Filter...":
myBrush = Brushes.DarkGreen;
backBrush = Brushes.PaleGreen;
e.Graphics.FillRectangle(backBrush, e.Bounds);
if (filterCommandFlag == 2)
{
e.Graphics.DrawLine(Pens.Green, e.Bounds.Left, e.Bounds.Bottom - 1, e.Bounds.Right, e.Bounds.Bottom - 1);
}
break;
case "Remove This Filter":
myBrush = Brushes.DarkGreen;
backBrush = Brushes.PaleGreen;
e.Graphics.FillRectangle(backBrush, e.Bounds);
break;
case "Remove All Filters":
myBrush = Brushes.OrangeRed;
backBrush = Brushes.PaleGreen;
e.Graphics.FillRectangle(backBrush, e.Bounds);
if (filterCommandFlag > 3 && filterCommandFlag < 8)
{
e.Graphics.DrawLine(Pens.Green, e.Bounds.Left, e.Bounds.Bottom - 1, e.Bounds.Right, e.Bounds.Bottom - 1);
}
break;
case "Blanks":
myBrush = Brushes.OrangeRed;
backBrush = Brushes.PaleGreen;
e.Graphics.FillRectangle(backBrush, e.Bounds);
break;
case "NonBlanks":
myBrush = Brushes.OrangeRed;
backBrush = Brushes.PaleGreen;
e.Graphics.FillRectangle(backBrush, e.Bounds);
if (filterCommandFlag > 7)
{
e.Graphics.DrawLine(Pens.Green, e.Bounds.Left, e.Bounds.Bottom - 1, e.Bounds.Right, e.Bounds.Bottom - 1);
}
break;
}
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
{
e.Graphics.FillRectangle(Brushes.SpringGreen, e.Bounds);
}
e.Graphics.DrawString(listString, e.Font, myBrush, e.Bounds, StringFormat.GenericDefault);
}
private void dropDownListBox_MeasureItem(object sender, MeasureItemEventArgs e)
{
Font font = dropDownListBox.Font;
SizeF stringSize = e.Graphics.MeasureString(font.Name, font);
e.ItemHeight = (int)stringSize.Height;
}
|
|
|
|
|
AFAIK the Windows ListBox does not support what you want. It insists on positioning the items itself, at best it will let you decide the height of an item, and let you draw the items. However to my knowledge it always scrolls everything. You may or may not paint your items outside the intended rectangle (part of the EventArgs), however I don't expect that to work properly.
I basically see two ways to get what you want, both taking more effort than you would hope:
1.
use a second ListBox, on top of the first, just showing the fixed items. And if their number and/or height isn't constant, that also means resizing/repositioning the ListBoxes.
2.
don't use a ListBox at all, in other words create your own.
And then of course there are companies that specialize in Controls (CodeProject is showing some ads for such companies) and may offer exactly what you want, but I'm not familiar with their offerings.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hey guys, I need to Develop a control that presents yearly calendar. that calender should show holidays and weekends each with a deferent color.
any body have a suggestion?
|
|
|
|
|
Before you begin you need to think!
Calendars are extremely complicated.
For a start you have to decide which calendar to use, what sort of information you require and how to lay it out.
Then you have the problems of fixed holidays, moveable feasts, leap years, etc.
Once you have decided, use the Calendar Control.
There are a few items in CP Archives...
Here is one[^].
Here is another[^].
Microsoft Page[^] on Calendar Control.
There are lots of options you can use, so be clear before you start what you need it for.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
Thanks Dalek, but i was talking about a windows Form Control.
|
|
|
|
|
Didn't see that requirement in the original question
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
Sorry Sir, It was my bad. But I thought that it was clear enough.
|
|
|
|
|
If you haven't already seen it, you might look at Another Month Calendar[^], for inspiration.
There is always the built-in MonthCalendar but highlighting in different colours is problematic.
In my experience Yearly Calendars are never the prettiest things, so if you do manage to produce something you are pleased with, you might consider writing an article about it.
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 wouldn't let CG touch my Abacus!
|
|
|
|
|
Sir, I have already Seen MounthCalender, but what i need is to show the user all holidays and weekends of a specified year at a once.
|
|
|
|
|
From a little research since your message, I would say this is going to be difficult.
This page[^] in Wikipedia has some links that may be useful.
This one[^] from StackOverflow has more links.
From a quick search it seems that it will largely depend on which culture you will be aiming at.
Can I suggest that you do some searching for list of public holidays or restrict it to a particular group list of islamic holidays.
I hope that this is of some help.
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 wouldn't let CG touch my Abacus!
|
|
|
|
|
Thank you for making your time trying to help me, you really reminding me with a friend of mine who really cares about me.
what i needed is a simple control that displays a year calendar
and i will need to provide a Holidays property, Weekends property, and some appearance properties.
Thank you again.
|
|
|
|
|
In that case I cannot help. I do not know of a ready made YearCalendar for WinForms. Sorry.
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 wouldn't let CG touch my Abacus!
|
|
|
|
|
Thank you, Sir.
100
|
|
|
|
|
Hello Friend
I am connectin Mysql in vb.net2008 on vista then its give error(Unable to connect to any of the specified MySQL hosts.) but whene i conectthis on xp os then its excute .... {}
My Code-
MySqlConnection _MySqlConnection;
MySqlCommand _MySqlCommand;
MySqlDataAdapter _MySqlDataAdapter;
string _Conentionstring = "server=localhost;database=schoolinventory;user id=root;password=;";
public int GetId()
{
try
{
_MySqlConnection = new MySqlConnection(_Conentionstring);
_MySqlConnection.Open();
string _Adpstring = "select Count(*) from goods";
_MySqlDataAdapter = new MySqlDataAdapter(_Adpstring, _Conentionstring);
DataSet _ds=new DataSet();
_MySqlDataAdapter.Fill(_ds);
int i = Convert.ToInt32( _ds.Tables[0].Rows[0].ItemArray[0].ToString());
return 0;
}
catch (Exception ex)
{
return 0;
}
}
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
Eventure Technology
http://holyschoolofvaranasi.blogspot.com
http://holytravelsofvaranasi.blogspot.com
|
|
|
|
|
I suggest you stop swallowing exceptions like that. Add Console.WriteLine(ex.ToString()); or something similar and see what it tells you.
|
|
|
|
|
5 - agreed
|
|
|
|
|
Do you have a MySQL server running on your Vista machine, with the same configuration and databases? At least your connection string says server=localhost. If it is on the XP machine only, you have to replace the name here, and you will likely have to some configuration on the server to allow connections from other computers. The Exception thrown will give you more details.
|
|
|
|
|
It could also be a firewall problem if the Windows Firewall blocks incoming requests on port 3306 (default port for MySQL services).
|
|
|
|
|
I see 1 posibility that spring to my mind.
- MySql Connector is not installed on your Vista.
|
|
|
|
|
I am make a report to display info about students but i have a record with each student with declare registration date of each student ,
My Question ? I am Display all info for students in report but i want to display the first value of date of first record and the last date of registered student to know the range (ex. From : 1/1/2010 to 1/2/2011) in the same report to be displayed in the header of the report ?
I want to know the steps ?
|
|
|
|
|
Which part of this are you having problems with?
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 wouldn't let CG touch my Abacus!
|
|
|
|
|
i WANT TO KNOW HOW I CAN DISPLAY ONLY THE FIRST VALUE OF DATE AND THE LAST VALUE OF DATE WHERE MY SQL COMMAND SELECT ALL ROWS.
report parts
- table to display all student info ( I do this)
- above the table I want to know how i can display date from : ...... to ......) ( I not know how i can do it ?
|
|
|
|
|
You do not state whether your database is Access, SQL Server, MySql, Oracle or whatever.
Still, on the chance that it might help, take a look at this[^] thread, where the OP has a similar problem.
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 wouldn't let CG touch my Abacus!
|
|
|
|
|