|
Hi,
I did both, the colors really get assigned. But they are just not visible. If i minimize the window and bringing it back to front, i can see the colors but disappear really fast again.
[EDIT 12:33h]
Hi,
It seems that i managed to fix this a bit. I created a paint event from the Form.
I do all the coloring stuff in there now. It seems that it keeps the colors, but if i select an item, it loses its color.
If i use the selectedIndexChanged event for the listview control, and i select an item, i lose all the colors on every item.
I need a way to call the Paint event inside the selectedIndexChanged event of the listview control. This might do the trick.
I tried this: this.frmMain_Paint(this.listviewcontrol, null);
But that didn't work...
[/Edit]
modified on Sunday, August 31, 2008 6:33 AM
|
|
|
|
|
For some reason the coloring is reset after you assign the color. Did the example I posted work corectly? If it did, I suggest that you comment code out so that you get painting correclty and then try to bring back code only in small pieces.
Also check the form's DoubleBuffered property. I believe it should be false.
|
|
|
|
|
i have this non rectangular window (spline-shaped) :
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace Guitar
{
class GuitarForm : Form
{
Bitmap bmp;
GuitarForm()
{
bmp = new Bitmap("C:\\ok.jpg");
GraphicsPath gp = new GraphicsPath();
Point[] curves = new Point[]{
new Point(93,99), new Point(200, 55),
new Point(328, 128),new Point(450,100),new Point(560,200),
};
gp.AddCurve(curves);
gp.AddLine(560,200, 560, 500);
gp.AddLine(560, 500, 93, 500);
gp.AddLine(93, 500, 93, 99);
gp.CloseFigure();
this.Region = new Region(gp);
}
protected override void OnPaint(PaintEventArgs ea)
{
base.OnPaint(ea);
Graphics g = ea.Graphics;
g.DrawImage(bmp, new Point(0, 0));
Rectangle scaled = new Rectangle(20, 20, 60, 60);
g.DrawImage(bmp,scaled);
g.DrawRectangle(Pens.Red, scaled);
Point[] pGram = new Point[]{
new Point(50, 10),
new Point(100, 30),
new Point(20, 100),
};
g.DrawImage(bmp, pGram);
}
public static void Main()
{
Application.Run(new GuitarForm());
}
private void InitializeComponent()
{
this.SuspendLayout();
this.ClientSize = new System.Drawing.Size(560, 560);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "GuitarForm";
this.ResumeLayout(false);
}
}}
the problem is that when i run it, only one part of the window appears and i have to drag to brders in order to see the whole shape . Is there any way it can run all-ready sized the way i want it ?
|
|
|
|
|
Could it be something as simple as this.Size = ...?
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
Click here to view my blog
|
|
|
|
|
Simple things always get me Thank you , Mark!
|
|
|
|
|
Hi ,
Is there any event for both the textchange and selectindexchange in combobox
{that event must fire when we made any change in the text as well as selectindexchange
|
|
|
|
|
There isn't, but just use both events and keep track of them yourself, like:
bool textChanged = false;
bool indexChanged = false;
void TextChanged()
{
if(!indexChanged)
textChanged = true;
else {
indexChanged = false
EventsFired();
}
}
void IndexChanged()
{
if(!textChanged)
indexChanged = true;
else {
textChanged = false
EventsFired();
}
}
void EventsFired()
{
}
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
there are no events for handle both events,
specify event handler like this:
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
this.comboBox1.TextChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
then you perfom actions in
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
this done because both events are apply from System.EventHandler
dhaim
programming is a hobby that make some money as side effect
|
|
|
|
|
how can i create new stencil bar in ms visio using c#.net and save, open, new file
tahir
|
|
|
|
|
|
I have a pre-printed invoices on dot matrix and i want to print the customers' invoices on it...
which method is best? printing to specefic point or use RDLC?
|
|
|
|
|
Hi,
You don't need a complicated algo. here, RDLC is more than enough.
good luck,
|
|
|
|
|
I binding the following to a datagrid:
private void get_all_vehicles()
{
dataVehicles.DataBindings.Clear();
data_table = new DataTable();
sql_connection = new SqlConnection("Data Source=.\\SQLEXPRESS;initial catalog=rent_a_car_company;integrated security=true");
sql_command = new SqlCommand("sp_populate_all_vehicles", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_adapter = new SqlDataAdapter(sql_command);
sql_adapter.Fill(data_table);
dataVehicles.DataSource = data_table;
dataVehicles.Columns["vehicle_id"].HeaderText = "ID";
dataVehicles.Columns["vehicle_id"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter;
dataVehicles.Columns["vehicle_id"].Width = 160;
dataVehicles.Columns["vehicle_id"].Visible = false;
dataVehicles.Columns["vehicle_photo"].HeaderText = "Photo";
dataVehicles.Columns["vehicle_photo"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter;
dataVehicles.Columns["vehicle_photo"].Width = 160;
dataVehicles.Columns["vehicle_make"].HeaderText = "Vehicle";
dataVehicles.Columns["vehicle_make"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter;
dataVehicles.Columns["vehicle_make"].Width = 160;
dataVehicles.Columns["vehicle_number"].HeaderText = "Number#";
dataVehicles.Columns["vehicle_number"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopLeft;
dataVehicles.Columns["vehicle_number"].Width = 200;
dataVehicles.Columns["category_name"].HeaderText = "Category";
dataVehicles.Columns["category_name"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopLeft;
dataVehicles.Columns["category_name"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataVehicles.Columns["category_name"].Width = 120;
dataVehicles.Columns["vehicle_shift"].HeaderText = "Shift";
dataVehicles.Columns["vehicle_shift"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopLeft;
dataVehicles.Columns["vehicle_shift"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataVehicles.Columns["vehicle_shift"].Width = 120;
dataVehicles.Columns["vehicle_rent_daily"].HeaderText = "Daily Rent";
dataVehicles.Columns["vehicle_rent_daily"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopLeft;
dataVehicles.Columns["vehicle_rent_daily"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataVehicles.Columns["vehicle_rent_daily"].DefaultCellStyle.Format = "#,###,###,##0.000";
dataVehicles.Columns["vehicle_rent_daily"].Width = 120;
sql_command.Dispose();
sql_adapter.Dispose();
sql_connection.Close();
}
also I am binding the following if the user clicked the vehicles out button:
private void get_vehicles_out()
{
dataVehicles.DataBindings.Clear();
data_table = new DataTable();
sql_connection = new SqlConnection("Data Source=.\\SQLEXPRESS;initial catalog=rent_a_car_company;integrated security=true");
sql_command = new SqlCommand("sp_populate_vehicles_out", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_adapter = new SqlDataAdapter(sql_command);
sql_adapter.Fill(data_table);
dataVehicles.DataSource = data_table;
dataVehicles.Columns["vehicle_id"].HeaderText = "ID";
dataVehicles.Columns["vehicle_id"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter;
dataVehicles.Columns["vehicle_id"].Width = 160;
dataVehicles.Columns["vehicle_id"].Visible = false;
dataVehicles.Columns["vehicle_photo"].HeaderText = "Photo";
dataVehicles.Columns["vehicle_photo"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter;
dataVehicles.Columns["vehicle_photo"].Width = 160;
dataVehicles.Columns["vehicle_photo"].Visible = false;
dataVehicles.Columns["out_category"].HeaderText = "Status";
dataVehicles.Columns["out_category"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter;
dataVehicles.Columns["out_category"].Width = 160;
dataVehicles.Columns["vehicle_make"].HeaderText = "Vehicle";
dataVehicles.Columns["vehicle_make"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter;
dataVehicles.Columns["vehicle_make"].Width = 160;
dataVehicles.Columns["vehicle_make"].HeaderText = "Vehicle";
dataVehicles.Columns["vehicle_make"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter;
dataVehicles.Columns["vehicle_make"].Width = 160;
dataVehicles.Columns["vehicle_number"].HeaderText = "Number#";
dataVehicles.Columns["vehicle_number"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopLeft;
dataVehicles.Columns["vehicle_number"].Width = 200;
dataVehicles.Columns["category_name"].HeaderText = "Category";
dataVehicles.Columns["category_name"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopLeft;
dataVehicles.Columns["category_name"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataVehicles.Columns["category_name"].Width = 120;
dataVehicles.Columns["category_name"].Visible = false;
dataVehicles.Columns["vehicle_shift"].HeaderText = "Shift";
dataVehicles.Columns["vehicle_shift"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopLeft;
dataVehicles.Columns["vehicle_shift"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataVehicles.Columns["vehicle_shift"].Width = 120;
dataVehicles.Columns["vehicle_rent_daily"].HeaderText = "Daily Rent";
dataVehicles.Columns["vehicle_rent_daily"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopLeft;
dataVehicles.Columns["vehicle_rent_daily"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
dataVehicles.Columns["vehicle_rent_daily"].DefaultCellStyle.Format = "#,###,###,##0.000";
dataVehicles.Columns["vehicle_rent_daily"].Width = 120;
dataVehicles.Columns["vehicle_rent_daily"].Visible = false;
sql_command.Dispose();
sql_adapter.Dispose();
sql_connection.Close();
}
and if you noticed, the only differnce is the column out_category which i am adding in the second code.
Now, the problem is: when the user clicks on the button displaying the first list then everything is fine but when the user clicks on the button invoking the second code it will just add the out_category column to the end which means it using the first codeand adding the out_category column when it should place the out_category column before the vehicle_make column.
so where is the problem?
|
|
|
|
|
You need to clear the columns too I think.
|
|
|
|
|
well, i only tried clearing the columns after facing this problem but it didn't solve it.
|
|
|
|
|
If I'm reading this correctly, you don't add columns on-the-fly, but use predefined columns and modify their properties (unless binding creates them). If that's the case, change the column order when adding columns to DataGridViewColumnCollection.
If the columns are added automatically by binding, change the order of columns in sp returning the result set or modify the order after population.
Hope this helps,
Mika
|
|
|
|
|
i hav already did that before posting this question.. here is my stored proceedure:
SELECT vehicles.vehicle_id, vehicles.vehicle_photo,
out_category = CASE vehicles.out_category
WHEN 'S' THEN 'STAFF'
WHEN 'C' THEN 'CUSTOMER'
WHEN 'R' THEN 'SERVICE'
WHEN 'W' THEN 'WORKSHOP'
END
, vehicle_makes.vehicle_make + ' ' + vehicle_brands.vehicle_brand + ' ' + LTRIM(STR(vehicles.vehicle_year)) AS vehicle_make, registration_types.registration_type + ' ' + vehicles.vehicle_registration_number AS vehicle_number, vehicle_category.category_name,
vehicle_shifts.vehicle_shift, vehicles.vehicle_rent_daily
FROM vehicles INNER JOIN
branches ON vehicles.branch_id = branches.branch_id INNER JOIN
vehicle_category ON vehicles.vehicle_category = vehicle_category.category_id INNER JOIN
vehicle_makes ON vehicles.vehicle_make = vehicle_makes.vehicle_make_id INNER JOIN
vehicle_brands ON vehicles.vehicle_brand = vehicle_brands.vehicle_brand_id INNER JOIN
registration_types ON vehicles.vehicle_registration_type = registration_types.registration_type_id INNER JOIN
vehicle_shifts ON vehicles.vehicle_shift = vehicle_shifts.vehicle_shift_id
WHERE vehicles.is_vehicle_out = 'True'
|
|
|
|
|
Ok, but most important: Are the columns already defined for dataVehicles before setting the DataSource?
|
|
|
|
|
no.. it's auto defined
i am using the auto defined columns for long time but this is the first time i face such a problem.
|
|
|
|
|
Before setting the DataSource for dataVehicles, use the debugger and check that the data_table is holding columns in right order (the order you have defined in sp), just in case that they arrive correctly.
If that doesn't explain this, add following lines before setting datasource to test if any of them help:
...
sql_adapter.Fill(data_table);
dataVehicles.DataSource = null;
dataVehicles.Columns.Clear();
dataVehicles.ResetBindings();
dataVehicles.DataSource = data_table;
...
|
|
|
|
|
checking the data_table shows that it's binding columns in the incorrect order agaist the order in the sp.
so i tried the code you mentioned and it worked fine.
thank you
|
|
|
|
|
You're welcome
|
|
|
|
|
Hi all..
Can anyone brief me with some examples to crawl repository from sharepoint server..
As i am new to sharepoint and as well as c#...I dont have idea regarding what exactly is Repository in sharepoint server...can anyone provide me site.....
thank you...in advance..
manju
Hi..
I am Mnaju.I have Completed my B.E Computers Science.Lokking for a job.I am interested in VC++
manju
|
|
|
|
|
How can i get automatic scroll bar in this project.http://www.codeproject.com/KB/graphics/PanZoom2.aspx?msg=2672101#xx2672101xx
sorry for posting link in this.
Regards,
ALGATES
|
|
|
|
|
|