|
Hai
I developing a software in c# i want to know how to write code for cute comboboxes for windows7.
anyone can help me please ?
Arunkumar
|
|
|
|
|
What do you mean by cute comboboxes for windows7?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
which frontend tech. you are using (WPF, Silverlight , etc.)?
"Insanity is doing the same thing over and over again but expecting different results.” — Rita Mae Brown
|
|
|
|
|
iam using .net as my desktop application framework
|
|
|
|
|
That is a web site, so you need to look at the options available within ASP.NET for creating drop down lists. There are lots of articles here on CodeProject that will offer suggestions.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thank you for your valuable time
I thing u misunderstand my question!
iam not looking for a asp.net combo box. i want to integrate that type of combo box in my desktop application.
Thank you
Arunkumar
|
|
|
|
|
I'm not sure Winforms or even WPF allows this kind of theming natively. What you'll need to do is write your own usercontrol that inherits from the standard combobox. I think this usercontrol will consist of several standard controls:
- a textbox
- a button (that resembles the down arrow)
- an invisible panel, size: width = textbox, height = 0 (by default)
You then load this panel with the items (via labels or textblocks) and on click of the button the panel grows in size (at the position right below the textbox). When a label/textblock was clicked, the panel is closed again andf the text put in the textbox.
hope this helps.
PS: Please avoid text speech and mind the spelling (even if you're not native English)
V.
|
|
|
|
|
I was thinking the same.
|
|
|
|
|
Yeah, genius minds think alike
V.
|
|
|
|
|
ok guys
Thanks for your replays
Now i am facing another problem
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Combo
{
public class Combo
{
private System.Windows.Forms.ComboBox li = new System.Windows.Forms.ComboBox();
public void Addselect(Control FormName, string name, int top, int left, int width, int height, string Text)
{
li.Top = top;
li.Left = left;
li.Width = width;
li.Height = height;
li.Name = name;
li.FlatStyle = FlatStyle.Flat;
li.CreateGraphics();
li.Text = Text;
li.IntegralHeight = false;
li.MaxDropDownItems = 5;
li.DropDownStyle = ComboBoxStyle.DropDown;
li.Size = new System.Drawing.Size(136, 81);
li.BackColor = System.Drawing.Color.DarkGray;
FormName.Controls.Add(li);
}
public void Additems(string[] items)
{
li.Items.AddRange(items);
}
public bool Enabled
{
get { return li.Enabled; }
set { li.Enabled = value; }
}
public bool Visible
{
get { return li.Visible; }
set { li.Visible = value; }
}
}
}
Iam Creating a library for combobox.(iam a newbie to c#)
iam using this library for adding many combobox in my form
can any one tell me how to create a selectedindexchanged event handler for each combobox i creating?
i tried the commented code but i got a error like this
Error 1 The type 'Combo.Combo' already contains a definition for 'SelectedIndexChanged' D:\SelectboxLibrary\SelectboxLibrary\Class1.cs 47 22 SelectboxLibrary
Please Hep me
Arunkumar
|
|
|
|
|
Lots of suggestions here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
WPF provides better styling support for controls.
|
|
|
|
|
Some replies here have assumed you are describing "theming:" (even though you never used that word, yourself): where theming means you want to create a control from which you could create any number of different look-and-feel variations from the base control.
Looking at your question: and the example on the web page you linked to: are you really asking how to create a custom-themed control, or are you just asking how to make a drop-down that looks and behaves exactly like the one on that web-page ?
Please clarify exactly what "style" and "styling" mean to you here.
best, Bill
"Last year I went fishing with Salvador Dali. He was using a dotted
line. He caught every other fish." Steven Wright
|
|
|
|
|
I have created a control based on System.Windows.Forms.TabControl. I am painting the entire control myself in order to paint custom tabs and such. This was created for in-house use and I have never had to use a TabControl in which the tabs extend the visible tab area. However, I would like to implement this in case I do need it in the future. However, when I shrink the control so that the left/right scroll buttons appear at the top-right, the tabs do not display correctly.
Here is the code I currently have for drawing the tabs, which works perfectly when there is no scrolling involved:
int tabX = 4;
int tabY = 4;
foreach (TabPage page in this.TabPages)
{
SizeF textSize = g.MeasureString(page.Text, this.Font);
Rectangle tabRect = new Rectangle(tabX, tabY, ((int)textSize.Width + 16), ((int)textSize.Height + 8));
LinearGradientBrush tabBrush = new LinearGradientBrush(tabRect, ThemeManager.Instance.CurrentTheme.FormBackgroundColor,
ThemeManager.Instance.CurrentTheme.ButtonBackgroundDark, 90.0f);
g.FillRectangle(tabBrush, tabRect);
if (this.SelectedTab == page)
g.DrawRectangle(new Pen(ThemeManager.Instance.CurrentTheme.SelectedItemBorderColor), tabRect);
else
g.DrawRectangle(new Pen(ThemeManager.Instance.CurrentTheme.ToolStripBorderColor), tabRect);
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
System.Drawing.Font font;
if (this.SelectedTab == page)
font = new System.Drawing.Font(this.Font, FontStyle.Bold);
else
font = this.Font;
g.DrawString(page.Text, font, Brushes.Black, tabRect, format);
tabX += (tabRect.Width + 4);
}
I know the code is a bit messy but right now I just want it to display correctly. This is mostly because I have never done this before so I am just trying to figure out how to make it LOOK right. Am I missing something here? I have looked at a few articles here on CodeProject which draw custom tabs. But I could not find anything in the code that handles this. I know it was done, I simply could not find where.
Any advice is appreciated. Thanks!
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|
|
Use GetTabRect to get the default bounds of a tab. You also need to override OnFontChanged to get the custom-draw tabs to report their size correctly; see for example this comment[^].
|
|
|
|
|
Hi,
Umm I have used the Serial Port class quite a bit never had any problems with it, but I have had some problems with the later boards we have produced and found I have to use a cludgy method shown below:
int i, j;
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(rtbOutgoing.Text);
j = rtbOutgoing.Text.Length;
for (i = 0; i < j; i++)
{
binaryWriter1.Write(bytes[i]);
}
rtbOutgoing.Text = "";
I have used it with no problems but a colleague got some of source hacked it around and said "Your code doesn't work!" in looking at he was doing ComPort.Write("saasa");
where as I do:
for (int i = 0; i < Length; i++)
{
CommandSent = Command1.Substring(j, 1);
myComPort.Write(CommandSent);
richTextBox1.Text += CommandSent;
j++;
}
myComPort.Write("\r\n");
He now blames his code not working and mine working on Windows or a bug in the Serial Port Write Method. My thinking was ComPort.Write("sasa") sends the string as a whole where my method splits up the string to individual characters. So is it Windows and the Serial Port Class at fault or the boards serial reading function. Interested in any similar experience any one has had.
Glenn
|
|
|
|
|
The thread a couple below this one may be of interest to you.
Dropping characters when sending as a whole but working one at a time sounds like you might have the baud rate set too high for the device with which you're trying to communicate.
|
|
|
|
|
Hi,
Yeah I did read the thread below but it didn't really answer my question of why does my method work (by splitting up the string and sending seperatly the characters) and the straight write method doesn't work. The baudrate is high but is the same I checked it before I wrote the code! (I'm an old hand at getting Windows to talk to the outside world).
Thanks for the reply though.
|
|
|
|
|
I haven't worked with serial ports in years, but this sounds a lot like either a handshaking problem, or an undersized receive buffer on the target system. Have you tried playing with these values?
Will Rogers never met me.
|
|
|
|
|
Ohh yeah, tried and failed the buffer has not changed from when it worked, what is going on, same means Write but if I split it with a substring it works if not FAIL! ??
|
|
|
|
|
glennPattonWork wrote: a colleague got some of source hacked it around
That is usually the problem. You may also note that his code looks like it is sending characters direct, which probably means they are still Unicode (i.e. 16 bits) whereas they need to be ASCII (8 bits).
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Actually the text-oriented methods apply an encoding, that is what the SerialPort.Encoding property is for. However, while the MSDN doc states it defaults at Encoding.ASCII , that is not in accordance with my experience; and that is why I either set the encoding explicitly, or, preferrably, transmit byte arrays, not char arrays or strings.
|
|
|
|
|
The sample that OP said did not work, didn't have any specific encoding, hence my comment.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I have been using serial ports quite a lot over the years, and I am unaware of any bug in Windows serial ports that could be relevant here.
Anyway, all your code snippets are doing is slow down the communication in different ways.
In my books, when a simple SerialPort.Write(byteArray, startIndex, length) doesn't work properly, then it is probably one of these two things:
- your serial bytes are bumping into each other due to a bit pattern format error (most common would be sending with just the one stop bit whereas the receiver may require 1.5 or 2)
- the receiver is badly designed and has a timing constraint, e.g. it needs more time to process a byte than it takes the byte to travel the serial line. Reducing the baud rate could solve this.
There are a lot of issues with serially receiving data, especially when data rates are high, and both throughput and latency are of high importance. Then Windows is tricky, as are many other systems. However, transmitting should never pose any problems.
Suggestion: try at lower baud rates first. I tend to develop comm protocols at 9600 Bd until they work perfectly, onlyu then turn up the baud rate.
Some random remarks:
- base-board serial ports tend to have good timing behavior; remote ports (such as USB serial cables, or Ethernet serial ports) tend to suffer delays and packetizing phenomena as they try not to send a whole package for each and every byte you want sent. So make sure to log the hardware aspects too when observing system behavior.
- make sure the GROUND signal in your serial cable is connected properly at both ends; a two-wire serial cable should not work, but it may occasionally work, be it intermittently.
- Windows knows how to buffer and dataflow the outgoing data, just like it does the incoming data; if you're unaware of this, it may continue for a while; and then stop sending data because the other side is "actively refusing to accept any more data". This depends on your handshake settings.
- make sure to setup and open the serial port once, then wait a while before exercising anything. Do not open and close all the time (a serial port is not a database!). That is recommended in general; and in particular in Windows where a fast close-open sequence is known to fail often (and that is a documented "feature").
|
|
|
|