|
how can i convert color form a hex format to a byte format? in other words how to convert from hex to argb
thx
|
|
|
|
|
You mean if you have 0xFFFFFF, how to turn that into argb ? Something like this
int color = 0xFFFFFF;
byte alpha = (byte)((color && 0xFF000000) << 24);
byte red = (byte)((color && 0xFF0000) << 16);
byte green = (byte)((color && 0xFF00) << 8);
byte blue = (byte)((color && 0xFF)));
Something like that. Use the && to strip the other bits, and a bit shift to move it down to be just a byte.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
so how can i get a value from a textbox and then convert it
|
|
|
|
|
Get the .Text string and then apply Christian's code to it.
|
|
|
|
|
Please, please, please buy a beginners book and read it.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
well here is the way i got it to work
<br />
int Color; <br />
Color = int.Parse(TextBox1.Text, NumberStyles.HexNumber); <br />
|
|
|
|
|
OK, what this does is not what you asked for. This gives you a a single number, no color information at all.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
If you have it as a string use ColorTranslator.FromHtml.
|
|
|
|
|
I have a DataGridView (called dgStandings) that has a datasource of a datatable (called dtLeader). I want to fire an event when someone double clicks a cell in the datagrid view and have a new window load with data depending on what cell is clicked. Unfortunately, none of the events I make (CellMouseDoubleClick,CellContentDoubleClick,CellMouseUp) ever fire an event. In fact, the events above only fire when I click/doubleclick on one of the header cells in dgStandings.
So how can I fire an event when I doubleclick a cell in dgStandings?
|
|
|
|
|
Please post code containing the declaration of the DataGridView, the loading of its data, and the methods you've created to handle the event(s). That should help get a clearer picture of what might be hanging you up.
|
|
|
|
|
hook to the DataGridView's CellDoubleClick event
if selecting by row do a
foreach (DataGridViewRow row in this.dgStandings.SelectedRows)<br />
{<br />
goGetYourNewDataMethodWhichTakesAString(row.Cells[0].Value.ToString());<br />
}
where the cell index is the cell you want
or for multiple cells
foreach (DataGridViewCell cell in this.dgStandings.SelectedCells)<br />
{<br />
goGetYourNewDataMethodWhichTakesAStringcell.Value.ToString();<br />
}
or even more simply
goGetYourNewDataMethodWhichTakesAString(this.dgStandings.SelectedCells[0].Value.ToString());
|
|
|
|
|
Hi,
I have a user control that has a textbox.
This user control is placed in a form at runtime. This form gives a string to the user control and the textbox is to show this in multiple lines.(i do so using a property to set the textbox's text property)
So in designer view i set the multiline property to TRUE and
the word wrap property to TRUE.
This enables the text to be shown in multiple lines at runtime.
But the textbox size does not grow according to the number of lines of text that it contains.
I dont want to use scrolls.
Please suggest how to set the size of the textbox to adjust according to the number of lines it has at runtime. So that all lines are shown. and i can accordingly place other contols below it.
Thanks
|
|
|
|
|
Write your own class derived from the textbox. When the user hits enter, measure the string, if it doesn't fit, make the textbox get bigger.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Christian
Thanks for replying.
In designer view, My textbox just fits in one line of string.
At runtime it could get a very long string.
Thus as Multiline is true the rest of the text comes in the next line and so on.
But unfortunetely my textbox size remains the same.
I need it to grow(vertically) with the numbers of line at runtime.
I dont want to use scroll bars.
could u please suggest how to go about this.
Thanks alot. really appreciate your help.
Karan
|
|
|
|
|
If you're not hitting enter to go to the next line, then you need on each keypress to use the measurestring method of hte graphics class to work out if the text is too big for the control, and if so, change it's size
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Christian
Thanks for the reply.
Will try this.
|
|
|
|
|
Hi all
at run time i add controls to form. i set controls contextmenu property to contextmenustrip1 whish has 3 sub menus. i wanna make something to control (like changing backcolor) when user click Menu1ToolStripMenuItem.
i need like at below
Private Sub Menu1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Menu1ToolStripMenuItem.Click<br />
sender)<br />
<br />
Menu1ToolStripMenuItem.Owner .ContextMenu .attainedControl.BackColor=red<br />
<br />
End Sub
How could i find "Attained Control"
|
|
|
|
|
Hi,
the sender parameter contains the sending object, you should cast it to what you expect,
here a menu item.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
i think u got me wrong.
i wanna catch which control has that context menu which button clicked.
|
|
|
|
|
|
|
Glad to help you
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
hy everyone!
i realized a console appliction which works perfect. but i was wondering what i will have to do to change it into a service dll?
i know the easiest way is to do it as a dll from the beginning. you are able to switch to dll instead of executable in the settings but this won't create a service dll which i am able to install.
does anyone of you have something like a "cookbook" of how to change a console appliction into a service dll? because this would help me a lot and it would avoid me having to start with my program once again.
thanks.
stephan.
|
|
|
|
|
|
yes, something like that.
but it only describes a service which does a console application. but my problem is: what do i have to do to add it to the list of services? isn't there a function like "onstart", "onstop" or "onrestart" (for all the actions which could be done in the services area"?
because the article describes a console application as a service. but you do have to get it into the services first and that's my question:
what do i have to add to my application to let it be started as a service like the one in the article above?!
|
|
|
|