4. There are segments of lengths $1, 2, \cdots, 9$, one of each. Now, select several segments to form a "segment group", and with this group of segments, a square can be exactly formed. Then the number of such segment groups is ( ).
(A) 5
(B) 7
(C) 9
(D) 11
4. C.

Obviously, using these segments to form a square requires at least 7 segments, and the side length of the square is at least 7.

Since $1+2+\cdots+9=45$, the side length of the square is no more than $\left[\frac{45}{4}\right]=11$, where $[x]$ denotes the greatest integer not exceeding the real number $x$.
Notice that
$$
\begin{array}{l}
7=1+6=2+5=3+4, \\
8=1+7=2+6=3+5, \\
9=1+8=2+7=3+6=4+5, \\
1+9=2+8=3+7=4+6, \\
2+9=3+8=4+7=5+6 .
\end{array}
$$

Therefore, forming a square with side lengths of 7, 8, 10, and 11, there is one method for each; forming a square with a side length of 9, there are five methods.
Thus, there are a total of 9 groups of segments that meet the conditions.