Click here to Skip to main content
15,915,094 members
Home / Discussions / C#
   

C#

 
AnswerRe: want the source code of Image Editor in C# windows application whose work like MS Paint Pin
Thomas Weller24-Nov-08 6:12
Thomas Weller24-Nov-08 6:12 
AnswerRe: want the source code of Image Editor in C# windows application whose work like MS Paint Pin
Shyam Bharath24-Nov-08 6:20
Shyam Bharath24-Nov-08 6:20 
AnswerRe: want the source code of Image Editor in C# windows application whose work like MS Paint Pin
DaveyM6924-Nov-08 8:53
professionalDaveyM6924-Nov-08 8:53 
GeneralRe: want the source code of Image Editor in C# windows application whose work like MS Paint Pin
Dan Neely24-Nov-08 8:57
Dan Neely24-Nov-08 8:57 
GeneralRe: want the source code of Image Editor in C# windows application whose work like MS Paint Pin
DaveyM6924-Nov-08 9:05
professionalDaveyM6924-Nov-08 9:05 
GeneralRe: want the source code of Image Editor in C# windows application whose work like MS Paint Pin
Dan Neely24-Nov-08 9:25
Dan Neely24-Nov-08 9:25 
GeneralRe: want the source code of Image Editor in C# windows application whose work like MS Paint Pin
Mark Churchill24-Nov-08 13:08
Mark Churchill24-Nov-08 13:08 
QuestionRepositioning Winform label in code, not working as expected Pin
Ben Fair24-Nov-08 4:15
Ben Fair24-Nov-08 4:15 
I have a windows forms application with a single form. On the form I have a ListView control in Details mode that I am using as a grid to display data; the ListView's Anchor property is set to all 4 edges (Top, Bottom, Left, Right), so it will retain it's distance to all edges when resized. The data is readonly, no changes will be made to it. The ListView has 4 columns, one of which is a dollar amount and I decided to put a Label control beneath the ListView control aligned with the amount column. In code, I set the label's Text to be the total of the amounts from the ListView's amount column; the label has no anchoring or docking and AutoSize is turned off. I decided that since the ListView columns can be resized and also the ListView itself can change size if the form is maximized or restored, then I'd like to move the label around so that it stays aligned with the amount column in the ListView. The ListView is named lstInvoices and the label is named lblTotalAmount. I hooked up the ListView's ColumnWidthChanged event handler like so:

private void lstInvoices_ColumnWidthChanged(object sender, ColumnWidthChangedEventArgs e)
{
    int columnIndex = lstInvoices.Columns.IndexOfKey(NETAMOUNT_COLUMN_NAME);
    if (columnIndex != -1 && (columnIndex == e.ColumnIndex) || (e.ColumnIndex == columnIndex - 1))
        AlignTotalLabelWithAmountColumn();
}


and here's the AlignTotalLabelWithAmountColumn function:

private void AlignTotalLabelWithAmountColumn()
{
    int columnIndex = lstInvoices.Columns.IndexOfKey(NETAMOUNT_COLUMN_NAME);
    if (columnIndex == -1)
        return;

    lblTotalAmount.Width = lstInvoices.Columns[columnIndex].Width;
    lblTotalAmount.Left = lstInvoices.Left;
    for (int i = 0; i < columnIndex; i++)
    {
        lblTotalAmount.Left += lstInvoices.Columns[i].Width;
    }
    lblTotalAmount.Top = lstInvoices.Bottom + 2;
}


In the function, I set the label's Width property to the same as the column in the ListView, and I calculate the Left position of the label by taking the Left of the ListView, plus the Width of each column up to the column I wish to line it up with. Last, I set the Top of the label to the Bottom of the ListView plus 2 pixels (for a small separation).

When I run it the Label shows up in the middle of the ListView. When I step through the code, I see that everything is set as expected and that (on my system, with 1280 x 1024 resolution) the Bottom property of lstInvoices is 920, so the Top property of lblTotalAmount is set to 922. But of course, the label is somehow rendered in the middle of the ListView and not at the coordinates I specified. If I resize the form and enter the code again, right at my breakpoint it shows the Top property of the label to be 523. It seems that even though I'm correctly setting the Top property of the label in the code, something is overriding that value and changing it to 523, but for the life of me I can't figure out what's causing it! Any ideas?

Keep It Simple Stupid! (KISS)

Questionfocusing in Windows App Pin
Pr@teek B@h!24-Nov-08 4:07
Pr@teek B@h!24-Nov-08 4:07 
AnswerRe: focusing in Windows App Pin
Giorgi Dalakishvili24-Nov-08 4:09
mentorGiorgi Dalakishvili24-Nov-08 4:09 
GeneralRe: focusing in Windows App Pin
Pr@teek B@h!24-Nov-08 4:10
Pr@teek B@h!24-Nov-08 4:10 
GeneralRe: focusing in Windows App Pin
Giorgi Dalakishvili24-Nov-08 4:15
mentorGiorgi Dalakishvili24-Nov-08 4:15 
QuestionProblem passing values between two windows forms. Pin
Gretna24-Nov-08 4:02
Gretna24-Nov-08 4:02 
AnswerRe: Problem passing values between two windows forms. Pin
Giorgi Dalakishvili24-Nov-08 4:07
mentorGiorgi Dalakishvili24-Nov-08 4:07 
QuestionCustom Installer using vb.net or c#.net - need help Pin
shw 23424-Nov-08 3:59
shw 23424-Nov-08 3:59 
AnswerRe: Custom Installer using vb.net or c#.net - need help Pin
shw 23424-Nov-08 16:45
shw 23424-Nov-08 16:45 
QuestionI am using Crystal Xcelsius, I want to integrate the Web service which is created on C#.net to Xcelsius XLF file Pin
Shaik Haneef24-Nov-08 3:38
Shaik Haneef24-Nov-08 3:38 
QuestionMulti line text on a button - is it possible Pin
bobpombrio24-Nov-08 3:19
bobpombrio24-Nov-08 3:19 
AnswerRe: Multi line text on a button - is it possible Pin
Luc Pattyn24-Nov-08 3:42
sitebuilderLuc Pattyn24-Nov-08 3:42 
GeneralRe: Multi line text on a button - is it possible Pin
bobpombrio24-Nov-08 4:01
bobpombrio24-Nov-08 4:01 
AnswerRe: Multi line text on a button - is it possible Pin
DaveyM6924-Nov-08 9:00
professionalDaveyM6924-Nov-08 9:00 
GeneralRe: Multi line text on a button - is it possible Pin
bobpombrio24-Nov-08 10:14
bobpombrio24-Nov-08 10:14 
GeneralRe: Multi line text on a button - is it possible Pin
DaveyM6924-Nov-08 11:59
professionalDaveyM6924-Nov-08 11:59 
GeneralRe: Multi line text on a button - is it possible Pin
bobpombrio25-Nov-08 1:08
bobpombrio25-Nov-08 1:08 
QuestionDllImport Question Pin
Pedram Behroozi24-Nov-08 2:33
Pedram Behroozi24-Nov-08 2:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.